java - How to Load Collection in hibernate which fetch type is Lazy? -
i using hibernate, spring , dozer in project .
my problem that unable load lazy fetching collection(list). using dozer convert entity class (dto) class. think dozer user know these things.
when debug data db in entity class when converted dto through dozer null in collection lazy fetched.
please me out here. in advance!
i unable developer list when converted entity dto. have exact dto classes name developer , founder , map these in string configuration file. tried @select on join table loaded , working fine don't want way . if have make function in servicemanager class me .
@entity @table(name = "table") public class founder { @id @column(name = "foun_id") @generatedvalue(generator = "uuid") private string id; @onetoone(fetch = fetchtype.eager, cascade = cascadetype.all, optional = false) @joincolumn(name = "reg_address_id") private address registeredaddress; @manytomany(fetch = fetchtype.eager, cascade = cascadetype.all) @jointable(name = "jointable", joincolumns = { @joincolumn(name = "foun_id", nullable = false) }, inversejoincolumns = { @joincolumn(name = "dev_id", nullable = true) }) private list<developer> developer; public string getid() { return id; } public void setid(string id) { this.id = id; } public address getregisteredaddress() { return registeredaddress; } public void setregisteredaddress(address registeredaddress) { this.registeredaddress = registeredaddress; } public list<developer> getdeveloper() { return developer; } public void setdeveloper(list<developer> developer) { this.developer = developer; } } @entity @table(name = "tbl") public class developer { @id @column(name = "dev_id") @generatedvalue(generator = "uuid") private string id; @column(name = "file_number") private string filenumber; @column(name = "flat_info") private string flatinfo; @onetoone(fetch = fetchtype.eager, cascade = cascadetype.all, optional = false) @joincolumn(name = "address_id") private address address; public string getid() { return id; } public void setid(string id) { this.id = id; } public string getfilenumber() { return filenumber; } public void setfilenumber(string filenumber) { this.filenumber = filenumber; } public string getflatinfo() { return flatinfo; } public void setflatinfo(string flatinfo) { this.flatinfo = flatinfo; } public address getaddress() { return address; } public void setaddress(address address) { this.address = address; } }
as wrote in comment, dozer access fields of founder , developer directly , ignoring getters. hibernate create proxies lazy loading, ends empty collections after conversion. consider changing class add mapping information getters instead of fields.
this question might useful - is possible configure dozer such default fields rather accessed directly through setter-/getter method
Comments
Post a Comment