-->
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: hibernate issue please solve this about date persistance
PostPosted: Thu Oct 11, 2007 12:33 pm 
Newbie

Joined: Thu Oct 11, 2007 9:35 am
Posts: 2
Location: COIMBATORE
Hi I am Please help me in this issue
the problem is i cant able to insert the values into the child table here

contact_method is parent table and
contact_relation ship is child table

The bellow is the query for creating the table
the hibernate mapping is also provided so please... help in this issue



The following are the create statements used to design the table in MySql database.











contact_relationship Table:



DROP TABLE IF EXISTS `testing`.`contact_relationship`;

CREATE TABLE `testing`.`contact_relationship` (

`Contact_id` int(10) unsigned NOT NULL,

`Contact_method` int(10) unsigned NOT NULL,

`Person_id` int(10) unsigned default NULL,

`Party_id` int(10) unsigned default NULL,

PRIMARY KEY (`Contact_id`,`Contact_method`),

KEY `FK_contact_relationship_1` (`Contact_method`),

KEY `FK_contact_relationship_2` (`Party_id`,`Contact_id`),

KEY `FK_contact_relationship_4` (`Person_id`,`Contact_method`),

KEY `FK_contact_relationship_5` (`Person_id`,`Contact_id`),

CONSTRAINT `FK_contact_relationship_1` FOREIGN KEY (`Contact_method`) REFERENCES `contact_type` (`Contact_Method`),

CONSTRAINT `FK_contact_relationship_2` FOREIGN KEY (`Party_id`, `Contact_id`) REFERENCES `party_contact` (`Party_id`, `Contact_id`),

CONSTRAINT `FK_contact_relationship_5` FOREIGN KEY (`Person_id`, `Contact_id`) REFERENCES `person_contact` (`Person_id`, `Contact_id`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1;



Contact_type Table



DROP TABLE IF EXISTS `testing`.`contact_type`;

CREATE TABLE `testing`.`contact_type` (

`Contact_Method` int(10) unsigned NOT NULL default '0',

`Contact_Type` varchar(45) NOT NULL,

PRIMARY KEY (`Contact_Method`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1;





Party_contact Table:



DROP TABLE IF EXISTS `testing`.`party_contact`;

CREATE TABLE `testing`.`party_contact` (

`Party_id` int(10) unsigned zerofill NOT NULL,

`Contact_id` int(10) unsigned NOT NULL,

PRIMARY KEY (`Party_id`,`Contact_id`),

KEY `FK_party_contact_1` USING BTREE (`Contact_id`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1;



Person_contact:



DROP TABLE IF EXISTS `testing`.`person_contact`;

CREATE TABLE `testing`.`person_contact` (

`Person_id` int(10) unsigned NOT NULL,

`Contact_id` int(10) unsigned NOT NULL,

PRIMARY KEY USING BTREE (`Person_id`,`Contact_id`),

KEY `FK_person_contact_1` USING BTREE (`Contact_id`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1;



Parent table xml mapping
-------------------------------
<hibernate-mapping>
<class name="com.hibernate.PersonContactPo" table="PERSON_CONTACT" schema="ODSCUST_OWNER">
<composite-id name="id" class="com.hibernate.PersonContactPoId">
<key-property name="personId" type="big_decimal">
<column name="PERSON_ID" precision="22" scale="0" />
</key-property>
<key-property name="contactId" type="big_decimal">
<column name="CONTACT_ID" precision="22" scale="0" />
</key-property>
</composite-id>

<set name="contactRelationshipPos" inverse="true">
<key>
<column name="PERSON_ID" precision="22" scale="0" />
<column name="CONTACT_ID" precision="22" scale="0" not-null="true" />
</key>
<one-to-many class="com.hibernate.ContactRelationshipPo" />
</set>
</class>
</hibernate-mapping>


Child table xml mapping
----------------------------
<hibernate-mapping>
<class name="com.hibernate.ContactRelationshipPo" table="CONTACT_RELATIONSHIP" schema="ODSCUST_OWNER">
<composite-id name="id" class="com.hibernate.ContactRelationshipPoId">
<key-property name="contactId" type="big_decimal">
<column name="CONTACT_ID" precision="22" scale="0" />
</key-property>
<key-property name="contactMethodId" type="big_decimal">
<column name="CONTACT_METHOD_ID" precision="22" scale="0" />
</key-property>
</composite-id>
<many-to-one name="personContactPo" class="com.hibernate.PersonContactPo" update="false" insert="false" fetch="select">
<column name="PERSON_ID" precision="22" scale="0" />
<column name="CONTACT_ID" precision="22" scale="0" not-null="true" />
</many-to-one>
<many-to-one name="partyContactPo" class="com.rci.pom.hibernate.PartyContactPo" update="false" insert="false" fetch="select">
<column name="PARTY_ID" precision="22" scale="0" />
<column name="CONTACT_ID" precision="22" scale="0" not-null="true" />
</many-to-one>
</class>
</hibernate-mapping>

_________________
HIBERNATE QUESTIONS


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.