-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: @ManyToOne noob problem
PostPosted: Sun May 23, 2010 12:26 pm 
Newbie

Joined: Sun May 23, 2010 12:15 pm
Posts: 1
Hello, I have 2 classes that I have a many to one association.

The Handler class:

@OneToMany(mappedBy = "handler", targetEntity=UnitOrder.class, cascade=CascadeType.ALL)
public List<UnitOrder> getUnitOrders() {
return unitOrders;
}

The unitOrder class:

@ManyToOne(cascade=CascadeType.ALL)
@JoinColumn(name="armyhandler_id")
public ArmyHandler getHandler() {
return handler;
}


I want to be able to find all of the incomplete orders using a findByExample(unitOrder) method, but it does not find any results even though I can see them in the database. I can access them through the handler class.

When I try an HQL:

Session session = HibernateUtil.getSession();

Query queryResult = session.createQuery("from unitorder");

System.out.println(queryResult.list());

I get the following exception:

Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: unitorder is not mapped [from unitorder]
[...]

Cany anybody help? This is particuarly frustrating as I wasnt expecting a problem here :(


Top
 Profile  
 
 Post subject: Re: @ManyToOne noob problem
PostPosted: Sun May 23, 2010 1:50 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Entity names and properties are case-sensitive in HQL. Try:

Code:
session.createQuery("from UnitOrder")


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.