File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Hibernate/Spring/Jboss Annotations + Entity Mapping problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate/Spring/Jboss Annotations + Entity Mapping problems" Watch "Hibernate/Spring/Jboss Annotations + Entity Mapping problems" New topic

Hibernate/Spring/Jboss Annotations + Entity Mapping problems

Bal Mark

Joined: Sep 27, 2002
Posts: 19
Hi All,

Hopefully someone can help with my problem, I'll give some detailed info below, but the summary is

I'm trying to map an Entity class to a property in another Entity, and I'm not having much luck, there's no error when jboss starts up, but when I try a hql query for example, I get an error 'could not resolve property'

in my applicationContext.xml I have

This is fine, seems to pickup the classes

my classes are more or less


the fields in the tables are
my_session ->
int id
int device_id
int session_id

device ->
int id
varchar guid

I tried using @Embedded for getDevice in the MySession class, but on queries it complained with something similar to 'cannot find column in field list' and the sql that was generated wasn't doing any join on the devices table, it was looking for device_id in the MySession's table.

When I try to do

it fails on the createQuery with

Thanks for reading this far, and hopefully you can help ;)
I'm trying to avoid any hbm.xml files (migrating away from all that at the moment) and hoping to use pure annotations

hmm what I'm basically trying to do with Annotations what you could do with

Do if I did a hql query "from MySession where device.guid = 'testguid' " ... it would return me the MySession with the Device that has guid = 'testguid'

Kindest regards

Bal Mark

Joined: Sep 27, 2002
Posts: 19
Am I way off the mark?

Should I be using @Embedded or just a simple

Device device = null;

and my problem lies elsewhere?

Wondering if it's some combination of incompatible jars

Am I wrong in thinking I can do this all through javax.persistence Annotations and settings the annotationclasses in the sessionFactory?

I could really use a few pointers .. so far swapping jars in /jboss/common/lib out and replacing with latest from the 3.6.5-final dist package has made no difference
Bal Mark

Joined: Sep 27, 2002
Posts: 19

I get the error

I'd have expected it to say, if it couldnt find the property guid, to complain about not finding it in the Device object, not the MySession object

Bal Mark

Joined: Sep 27, 2002
Posts: 19
Right so ..

Turns out its all down to where Iw as putting my annotations,
I thought it'd be ok to put them around the variables or getters or mix and match

but to get it working,

I moved all the @Column annotations before the getters.. hey presto .. works ;)



I agree. Here's the link:
subject: Hibernate/Spring/Jboss Annotations + Entity Mapping problems
It's not a secret anymore!