Tuesday, 15 July 2014

JPA Query org.hibernate.QueryException: could not resolve property -


I have @OneToOne between two of the following tables in a two-directional relationship:

< Pre> Import javax.preistence.Entity; Import javax.preistence.GeneratedValue; Import javax.preistence.GenerationType; Import javax.preistence.Id; Import javax.preistence.JoinColumn; Import javax.preistence.OneToOne; Import javax.preistence.Table; @ Entity @ Public Class Student Official Domainmald Implementation {@Id @GeneratedValue (strategy = GenerationType.AUTO) Private Integer idstudentaccount; @OneToOne (optional = false) @ join column (name = "idstudent") Private student student; Private string user name; Private string password; // Gestors and Setters} Entity @Table (name = "student") apply the public class student domain modell {@Id @GeneratedValue (strategy = GenerationType.AUTO) private integer idStudent; Private string firstname; Private string last name; @OneToOne (mapped = "student", cascade = cascade type .al, target entity = student account.class) private student account students; // getters and setters

How to write a question to know if a username exists in the database? This is what I have done:

  @transactional @Override Public Boolean username (record user name, integer student id) {query check user name = getEntityManager (.createQuery (select " COUNT (*) student ACCOUNT with WHERE s.username =: usernameParam and s.idstudent <>: accIdParam "); Check username .setpaymator ("user name", user name); Check Username. Sitemapator ("ACCIADPARM", Student ID); Long calculation = (long) check username GETSINGAL RESULTS (); If (count> gt; {true} }     return false; }  

and I get the following exception:

  java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve the property: idstudent of : Com.f.domain The student account  

This should be s.student.idstudent & lt; & Gt ;: accIdParam

Remember that s see a nested student with property StudentAccount Another nested idStudent property


No comments:

Post a Comment