Edit:
Ok i think i have it.....i must insert all that 3 codes (attach below "End Edit" in text...) into person.hbm.xml. But my other question, what i must do with Administrator.hbm.xml? I ever become an error; duplicatet class/ entity. When i delete that file, its ok, when i try to make "from Administrator a" i recive an error. ok.I have thought, that i use for every Table an own mapping-file. how i must do that if i extend a class. must i implement only the superclass.hbm.xml and must insert there the <joined-classes> statement?
Further i think that should be a right hql-statement?
"from Person p, Benutzer b" But with my actual person.hbm.xml it works not for me...
Here is my new Person.hbm.xml:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 05.05.2009 18:09:10 by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
<class name="org.logbuch.Person" table="Person" catalog="logbuch20">
<id name="Id" type="int">
<generator class="native" />
</id>
<property name="nachname" type="string">
<column name="Nachname" length="50" not-null="true" />
</property>
<property name="vorname" type="string">
<column name="Vorname" length="50" not-null="true" />
</property>
<property name="adresse" type="string">
<column name="Adresse" length="50" not-null="true" />
</property>
<property name="plz" type="int">
<column name="Plz" not-null="true" />
</property>
<property name="ort" type="string">
<column name="Ort" length="50" not-null="true" />
</property>
<joined-subclass name="org.logbuch.Benutzer" table="Benutzer">
<key column="Id"/>
<property name="email" type="string">
<column name="Email" length="50" not-null="true" />
</property>
<property name="passwort" type="string">
<column name="Passwort" length="50" not-null="true" />
</property>
</joined-subclass>
<joined-subclass name="org.logbuch.Administrator" table="Administrator">
<key column="Id"/>
<property name="email" type="string">
<column name="Email" length="50" not-null="true" />
</property>
<property name="passwort" type="string">
<column name="Passwort" length="50" not-null="true" />
</property>
</joined-subclass>
</class>
</hibernate-mapping>
if i try my example-statement i receive:
Code:
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of org.logbuch.Person.Id
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
at org.hibernate.engine.UnsavedValueFactory.getUnsavedIdentifierValue(UnsavedValueFactory.java:44)
at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:44)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:123)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
at org.hibernate.persister.entity.JoinedSubclassEntityPersister.<init>(JoinedSubclassEntityPersister.java:91)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:58)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
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:597)
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:145)
... 12 more
I dont understand...
whats going wrong there...
Thanks for all help.
Cheers
Manuel