Ali Abbas
Ali Abbas

Reputation: 488

parent record in hibernate query

I am facing a a problem using zkoss with hibernate

I have Two models one is JuvenileInfo other is SchoolMeasure

In SchoolMeasure I have created a manyToOne relationship

@Transient @ManyToOne @JoinColumn(name = "juvenile_id", nullable = false) public JuvenileInfo juvenile;

When I access

SessionFactory sessionFactory = new Configuration().configure() .buildSessionFactory();

Session session = sessionFactory.openSession(); session.beginTransaction(); List result1 = session.createQuery( "from ShoolBasedMeasure e inner join e.juvenile ") .list();

I got error juvenile is not property , So anyone can help me how I get parent record list view to show its any column

Upvotes: 1

Views: 59

Answers (1)

Bonifacio
Bonifacio

Reputation: 1502

The error is caused because you're using @Transient annotation. @Transient annotation should be used only on not-persisted attributes, which is probably your problem, simply because Hibernate can't find the transient attributes in the database.

In this case you should do one of the following solutions:

  1. If juvenile is a persistent attribute, then you should remove the @Transient annotation of it;
  2. If juvenile is NOT a persistent attribute and you are using it only for a logic that need this attribute, then you should remove the mappings @ManyToOne and @JoinColumn;

Based on what you are describing, the first solution will probably works, let us know if it solves your problem.

Upvotes: 1

Related Questions