private Map < String , List < String > > mapClazztoPu ( Class < ? > clazz , String pu , Map < String , List < String > > clazzToPuMap ) { List < String > puCol = new ArrayList < String > ( 1 ) ; if ( clazzToPuMap == null ) { clazzToPuMap = new HashMap < String , List < String > > ( ) ; } else { if ( clazzToPuMap . containsKey ( clazz . getName ( ) ) ) { puCol = clazzToPuMap . get ( clazz . getName ( ) ) ; } } if ( ! puCol . contains ( pu ) ) { puCol . add ( pu ) ; clazzToPuMap . put ( clazz . getName ( ) , puCol ) ; String annotateEntityName = clazz . getAnnotation ( Entity . class ) . name ( ) ; if ( ! StringUtils . isBlank ( annotateEntityName ) ) { clazzToPuMap . put ( annotateEntityName , puCol ) ; } } return clazzToPuMap ; }
Method to prepare class simple name to list of pu s mapping . 1 class can be mapped to multiple persistence units in case of RDBMS in other cases it will only be 1!