-->
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.  [ 1 post ] 
Author Message
 Post subject: using entity-name and join - is it possible?
PostPosted: Wed Apr 20, 2005 10:25 am 
Newbie

Joined: Sun Mar 06, 2005 7:57 pm
Posts: 4
For accessing a legacy database structure, I've implemented Interceptor.getEntityName() which seems to be a (dirty but acceptable) work-around for saving the same class in different tables.
http://forum.hibernate.org/viewtopic.php?t=939568

However, now I was trying to use a join mapping for an object's content which is distributed between two tables (e.g. users and userdetails). Because of the entity-name defined for the mapping, the join fails.

=> Is there any way to work around this one as well to be able to use join between multiple mappings of the same class with different entity-names?

Thanks in advance for your help!



mapping (excerpt)
(note: this mapping document is added multiple times for different ${APPID}, so there is one group of database tables per application)

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="test.TestUser"
table="${APPID}_userNEW" entity-name="user_${APPID}">

<id name="id" column="userID" type="long">
<generator class="native"/>
</id>

<property name="applicationId" formula="${APPID}" />
<property name="username" column="username" type="string" />
<property name="password" column="password" type="string" />
<property name="status" column="status" type="integer" />


<join table="${APPID}_userdetailsNEW">
<key column="userID"/>
<property name="firstName" column="firstname" />
<property name="lastName" column="lastname" />
<property name="email" column="email" />
<property name="mobile" column="mobile" />
</join>

</class>

</hibernate-mapping>



stacktrace

org.hibernate.MappingException: org.hibernate.MappingException: class user_1 not found while looking for property: firstName
at org.hibernate.cfg.Configuration.addXML(Configuration.java:317)
at test.TestClass.main(TestClass.java:394)
Caused by: org.hibernate.MappingException: class user_1 not found while looking for property: firstName
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:81)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:230)
at org.hibernate.cfg.HbmBinder.createProperty(HbmBinder.java:1751)
at org.hibernate.cfg.HbmBinder.bindJoin(HbmBinder.java:884)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:1723)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:315)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:233)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:149)
at org.hibernate.cfg.Configuration.add(Configuration.java:358)
at org.hibernate.cfg.Configuration.addXML(Configuration.java:313)
... 3 more
Caused by: java.lang.ClassNotFoundException: user_1
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:103)
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:77)
... 12 more
Exception in thread "main" java.lang.NullPointerException
at test.Testclass.main(Testclass.java:394)


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

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.