is it possible to map one database table to several pojo?
& if i map 1 table to 1 class hierarchy then is it necessary that only the parent class should contain the attribute representing the primary key ?
is it possible to map one database table to several pojo?
& if i map 1 table to 1 class hierarchy then is it necessary that only the parent class should contain the attribute representing the primary key ?
plz tell me how?
can i do it like :
<class name="class1" table="table1">
<property name="p1" column="p1"/>
</class>
<class name="class3" table="table1">
<property name="p3" column="p3"/>
</class>
<class name="class2" table="table1">
<property name="p2" column="p2"/>
</class>
yeah.
this is my db table :
and its my .hbm.xmlcreate table User(
ComponentId numeric primary key not null,
UniqueCode varchar(20) unique,
VersionNumber varchar(20),
CreationDate date,
Status varchar(20),
UserId varchar(20)unique,
Name varchar(20),
Email varchar(40),
Password varchar(20),
Description varchar(40)
);
and here is the exception i'm getting:<class name="com.vonair.nexus.core.BusinessEntity" table="User" >
<property name="description" column="Description" />
</class>
<class name="com.vonair.nexus.core.PersistenceCapableDTO" table="User">
<id name="componentId" column="ComponentId" >
<generator class="increment" />
</id>
<property name="uniqueCode"column="UniqueCode" />
<property name="versionNumber" column="VersionNumber" />
<property name="creationDate" column="CreationDate" />
<property name="status" column="Status" />
</class>
<class name="com.vonair.nexus.user.UserDTO"
table="User">
<property name="userId" column="UserId" />
<property name="password" column="Password" />
<property name="name" column="Name"/>
<property name="email" column="Email" />
</class>
org.hibernate.InvalidMappingException: Could not parse mapping document
Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tu plizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|ar ray|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)".
Can you provide whole hbm.xml? I see at least one problem in provided xml:
(There are no space between " and column)Code:<property name="uniqueCode"column="UniqueCode" />
thank u for helping.
here is the whole file:
<?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>
<class name="com.vonair.nexus.core.PersistenceCapableDTO" table="User">
<id name="componentId" column="ComponentId" >
<generator class="increment" />
</id>
<property name="uniqueCode" column="UniqueCode" />
<property name="versionNumber" column="VersionNumber" />
<property name="creationDate" column="CreationDate" />
<property name="status" column="Status" />
</class>
<class name="com.vonair.nexus.user.UserDTO"
table="User">
<property name="userId" column="UserId" />
<property name="name" column="Name"/>
<property name="password" column="Password" />
<property name="email" column="Email" />
</class>
<class name="com.vonair.nexus.core.BusinessEntity" table="User" >
<property name="description" column="Description" />
</class>
</hibernate-mapping>
UserDTO and BusinessEntity class configurations are not valid. They haven't id tag
thaaaaaaaaaanks
thaaaaaanks, its working