Hibernate version: 2.1
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="Person">
<id name="id" column="personId" type="int">
<generator class="native"/>
</id>
<join table="PersonAddress"
optional="true">
<key column="personId" unique="true"/>
<many-to-one name="address"
column="addressId"
not-null="true"/>
</join>
</class>
<class name="Address">
<id name="id" column="addressId" type="int">
<generator class="native"/>
</id>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using: MYSQL version 3.1
The generated SQL (show_sql=true):
[schemaexport] drop table if exists Address;
[schemaexport] 14:14:06,368 DEBUG SchemaExport:132 - drop table if exists Address;
[schemaexport] drop table if exists Person;
[schemaexport] 14:14:06,368 DEBUG SchemaExport:132 - drop table if exists Person;
[schemaexport] create table Address (
[schemaexport] addressId integer not null auto_increment,
[schemaexport] primary key (addressId)
[schemaexport] );
[schemaexport] 14:14:06,368 DEBUG SchemaExport:149 - create table Address (
[schemaexport] addressId integer not null auto_increment,
[schemaexport] primary key (addressId)
[schemaexport] );
[schemaexport] create table Person (
[schemaexport] personId integer not null auto_increment,
[schemaexport] primary key (personId)
[schemaexport] );
[schemaexport] 14:14:06,383 DEBUG SchemaExport:149 - create table Person (
[schemaexport] personId integer not null auto_increment,
[schemaexport] primary key (personId)
[schemaexport] );
[schemaexport] 14:14:06,399 INFO SchemaExport:160 - schema export complete
BUILD SUCCESSFUL
Total time: 5 seconds
Debug level Hibernate log excerpt:
Hi All,
I am new to hibernate. I just want to create two classes and want to establish relation between them
i am able to everything but its not creating PersonAddress table that is mentioned. Can i know y it is not creating the Table. I am able to create Person and Address. Please help me...
Thanks
Madhuri
|