-->
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.  [ 4 posts ] 
Author Message
 Post subject: howto annotate maps w/composite primary key
PostPosted: Tue Dec 13, 2005 12:08 pm 
Beginner
Beginner

Joined: Wed Dec 17, 2003 2:54 pm
Posts: 26
Location: Oslo, Norway
Hibernate version: 3.1 + annotations 3.1beta7

Mapping documents:
@Entity(access = AccessType.FIELD)
@Table(name="phyDev")
public class PhyDev {
@Id(generate=GeneratorType.AUTO) private Long phyDevID;
@OneToMany(mappedBy="phyDevID") @MapKey(name="propKey") private Map<String, PhyDevSettings> settings;
(...)
}

@Entity(access=AccessType.FIELD)
@Table(name="phyDevSettings")
@IdClass(PhyDevSettingsPk.class)
public class PhyDevSettings {
(...)
public Long phyDevID;
public String propKey;
}

@Embeddable(access=AccessType.FIELD)
public class PhyDevSettingsPk implements Serializable {
public Long phyDevID;
public String propKey;
(...)
}

Code between sessionFactory.openSession() and session.close():
N.A.

Full stack trace of any exception that occurs:
junit.framework.AssertionFailedError: Caught unexpected exceptionorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext-backoffice.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: property not found: phyDevID on entity no.telio.model.PhyDevSettings
at junit.framework.Assert.fail(Assert.java:47)
at no.telio.provisioning.servlet.ProvServletBasicTestCase.testWrongUserAgent(ProvServletBasicTestCase.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

Name and version of the database you are using:
Mysql 4.1.15

The generated SQL (show_sql=true):
N.A.

Debug level Hibernate log excerpt:
(...)
DEBUG Second pass for collection: no.telio.model.PhyDev.settings (CollectionSecondPass.java:33)
DEBUG Binding a OneToMany: no.telio.model.PhyDev.settings through a foreign key (CollectionBinder.java:441)
INFO Mapping collection: no.telio.model.PhyDev.settings -> phyDevSettings (CollectionBinder.java:471)
DEBUG Retrieving property no.telio.model.PhyDevSettings.phyDevID (TableBinder.java:154)

Database schema for phyDev:
CREATE TABLE `phyDev` (
`phyDevID` int(11) NOT NULL auto_increment,
(...)
);

CREATE TABLE `phyDevSettings` (
`phyDevID` int(11) NOT NULL default '0',
`propKey` varchar(32) NOT NULL default '',
(...)
);

I am trying to map the above schema using annotations with little luck. The documentation does not seem to cover this specific instance, but I may very well have
missed something.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 16, 2005 7:21 am 
Beginner
Beginner

Joined: Wed Dec 17, 2003 2:54 pm
Posts: 26
Location: Oslo, Norway
Ok, now I am getting worried. Nobody has replied, and here I am not knowing wether that is because

1) I have asked a ridiculous question, or not given enough information
2) What I have asked isn't possible (yet)
3) There is some source of information I have missed, which I should have found.

Please - can someone yell at me if 1 or 3 applies, so I know which way to take this further?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 7:22 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Check the HA unit test suite, in o.h.t.a.indexcoll.Painter/Painting/PaintingPk, there is the same example.
If you can make it fail by changing part of it, post it to JIRa I'll ahve a look.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 10:44 am 
Beginner
Beginner

Joined: Wed Dec 17, 2003 2:54 pm
Posts: 26
Location: Oslo, Norway
ANN-180

http://opensource2.atlassian.com/projects/hibernate/browse/ANN-180

As I said in the test, the test may be totally broken.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.