java - List of Hashmap in one to many relationships -



java - List of Hashmap in one to many relationships -

i have 2 tables relationship of one-to-many. need categorize sub-table (many part) categories , display them. example, have part , product table. 1 part have many products, there many products belong specific category , going display them 1 section. want like:

@entity public class part { // ... codes here @onetomany(fetch = fetchtype.lazy) private list<hashmap<long, list<product>>> productentities; // ... codes here }

any suggestions please?

here doing. appreciate if improve solution.

@entity public class part { // ... codes here @onetomany(fetch = fetchtype.lazy) private list<product> productentities; @transient private hashmap<long, list<product>> productsmap; public hashmap<long, list<product>> getproductsmap() { if (productentities!= null) { (product product : productentities) { list<product> productlist = productsmap.get(product.getproducttypeentity().getid()); if (productlist == null) { productlist= new arraylist<product>(); } productlist.add(product); productsmap.put(product.getproducttypeentity().getid(), productlist); } } homecoming productsmap; } // ... rest of codes }

java jpa map one-to-many

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -