AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

anfängerhänger bei hibernate

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Language (German)
View previous topic :: View next topic  
Author Message
Ben Schoerer
Guest





PostPosted: Sun May 06, 2007 2:11 am    Post subject: anfängerhänger bei hibernate Reply with quote



hallo allerseits,

ich will mich mal mit hibernate beschäftigen und hab grad nen hänger bei
der "table-by-subclass"-strategie (table-per-classhierarchy hat
wunderbar geklappt)

meine simple klassenhierarchie sieht so aus

Quote:

class BusinessObject {

Long id;
String name;
}

class User extends BusinessObject {
String nick;
String email;
}
<<<

und ich hab folgende mapping-datei

Quote:

?xml version="1.0"?

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="de.hibernate.test">
<class name="BusinessObject" table="BUSINESSOBJECT">
<id name="id" type="long" column="id">
<generator class="native"/>
</id>
<property name="name" type="string" />
</class>
<joined-subclass name="User" table="USER" extends="BusinessObject">
<key column="id"/>
<property name="email" type="string" />
<property name="nick" type="string" />
</joined-subclass>
</hibernate-mapping>
<<<

Aber es wird nur die BusinessObject-Tabelle angelegt und beim Einfügen
meckert er natürlich das er nichts in die User-Tabelle eintragen kann

Quote:

[java] Hibernate: insert into BUSINESSOBJECT (name, id) values (?, ?)

[java] Hibernate: insert into USER (email, nick, id) values (?, ?, ?)
[java] Exception in thread "main"
org.hibernate.exception.SQLGrammarException: could not insert:
[de.hibernate.test.User]
<<<

irgendwie find ich im hibernate-tutorial da nix zu bzw. da steht das so
drin ...

bin für jeden fingerzeig dankbar

ben
Back to top
Michael Plate
Guest





PostPosted: Tue May 08, 2007 11:25 pm    Post subject: Re: anfängerhänger bei hibernate Reply with quote



Hallo Ben,

ich hab mir gerade dein Problem angeschaut und bei mir läuft das ohne
Probleme. Falls das Problem noch akut ist, kannst du mir die Configuration -
Datei von Hibernate und DB Statement posten.

Gruss
Michael Plate

"Ben Schoerer" <b.schoerer (AT) web (DOT) de> schrieb im Newsbeitrag
news:5a4a6qF2m9u71U1 (AT) mid (DOT) uni-berlin.de...
Quote:
hallo allerseits,

ich will mich mal mit hibernate beschäftigen und hab grad nen hänger bei
der "table-by-subclass"-strategie (table-per-classhierarchy hat
wunderbar geklappt)

meine simple klassenhierarchie sieht so aus


class BusinessObject {
Long id;
String name;
}

class User extends BusinessObject {
String nick;
String email;
}


und ich hab folgende mapping-datei


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

hibernate-mapping package="de.hibernate.test"
class name="BusinessObject" table="BUSINESSOBJECT"
id name="id" type="long" column="id"
generator class="native"/
/id
property name="name" type="string" /
/class
joined-subclass name="User" table="USER" extends="BusinessObject"
key column="id"/
property name="email" type="string" /
property name="nick" type="string" /
/joined-subclass
/hibernate-mapping


Aber es wird nur die BusinessObject-Tabelle angelegt und beim Einfügen
meckert er natürlich das er nichts in die User-Tabelle eintragen kann


[java] Hibernate: insert into BUSINESSOBJECT (name, id) values (?, ?)
[java] Hibernate: insert into USER (email, nick, id) values (?, ?, ?)
[java] Exception in thread "main"
org.hibernate.exception.SQLGrammarException: could not insert:
[de.hibernate.test.User]


irgendwie find ich im hibernate-tutorial da nix zu bzw. da steht das so
drin ...

bin für jeden fingerzeig dankbar

ben
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Language (German) All times are GMT
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.