java - Unable to retrieve hibernate foreign keys from a servlet context -


i can't read ids of referenced entities using hibernate, tomcat , mysql.

example, running following code:

list<useraccount> users = listentities(useraccount.class);     (useraccount user : users) {         useraccountstatuscatalog status = user.getstatus();         system.out.println("[user (" + user.getid() + ") : "+user.getaccountname()+"] - " + status + ": " + status.getid());     }  

will give following output in simple java application or servlet context using sql server db

[user (1) : system] - suspended: 15020
[user (2) : admin] - active: 15010
[user (4) : test] - active: 15010

and within servlet context using mysql db

[user (1) : system] - suspended: 0
[user (2) : admin] - active: 0
[user (4) : test] - active: 0

this on tomcat 7 server running java 8
database mysql 5.5 , i'm using hibernate-core:5.1.0.final

i have tested lot of different approaches such changing hibernate version, changing db mariadb (not working) , sql server (works perfectly).
i've tested on tomcat 6,7 , 8 (same result, not working)
tested on java 7 , 8 (same result, not working)

entities

@entity(name = "useraccount") @table(name = "user_account") @audited public class useraccount {       @manytoone(optional = false, fetch = fetchtype.lazy)     @joincolumn(name="id_status", nullable=false, foreignkey=@foreignkey(name = foreignkeys.fk_useraccount_status))     @audited(targetauditmode = relationtargetauditmode.not_audited)     private useraccountstatuscatalog status;     [...]   @entity @table(name="user_account_status_catalog") public class useraccountstatuscatalog {     @id     @generatedvalue(strategy = generationtype.identity)     @column(name = id_column_name, nullable = false)     private int id;      @column(name = "name", nullable = false)     private string name; } 

so question is
have experience particular issue or have pointers can continue debugging since i'm out of ideas do.

so managed solve on own. turns out culprit javassist-3.16.0 import. after replacing old version javassist3.20.0 import worked way supposed to.

so experiencing similar problems, replacing import place start.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -