Wednesday, 15 August 2012

java - Entitymanager query in 2 different tables with inner join -



java - Entitymanager query in 2 different tables with inner join -

my current code:

typedquery<account> tp = em.createquery("select business relationship inner bring together user u on u.account_id = a.id a.email = :email , a.pwd = :pwd , a.role = 'admin'", account.class); tp.setparameter("email", this.username); tp.setparameter("pwd", this.password); business relationship result = tp.getsingleresult();

but sick java.lang.illegalargumentexception.

what need display column in user table.

something string name = account.getname(); business relationship entity doesnt have getname() user entity has.

*update

this error

java.lang.illegalargumentexception: exception occurred while creating query in entitymanager: exception description: syntax error parsing query [select business relationship inner bring together user u on u.account_id = a.id a.email = :email , a.pwd = :pwd , a.role = 'admin']. internal exception: org.eclipse.persistence.internal.libraries.antlr.runtime.earlyexitexception

try this.

result.getuser().getname();

this, though, under assumption, business relationship class has relationship user class.

the assumption of beingness hibernate/jpa relationship comes previous question , utilize hql in code above.

java jpa

No comments:

Post a Comment