File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes How toPersist Value in the Tables Using Entity Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How toPersist Value in the Tables Using Entity Bean" Watch "How toPersist Value in the Tables Using Entity Bean" New topic
Author

How toPersist Value in the Tables Using Entity Bean

Rahman ziaur
Greenhorn

Joined: Mar 30, 2011
Posts: 23

Hi All Suppose i have two table Parent and child.
Parent table having one Primary key and my Child table contaion child_id as primary key and Parent_id as foriegn key.
There is oneto Many relationship among my tables.
Please help me i could i save the value in Child table for foriegn key.
I am able to persist value in Parent table but not able in Child table.Is it any way through which i insert in parent and its automaticaaly reflect on Child table.


Any suggestion,help must be Appreciated.
Thanks in Advance.
Komal Renu
Ranch Hand

Joined: Jul 21, 2011
Posts: 51
Could you please list out more details ? architecture etc
Rahman ziaur
Greenhorn

Joined: Mar 30, 2011
Posts: 23

I have two table--
1-[code=javaCREATE TABLE `ttdb`.`competence` (
`competence_id` int(10) unsigned NOT NULL auto_increment,
`competence_name` varchar(45) NOT NULL,
`competence_desc` varchar(100) default NULL,
`competence_status` varchar(45) NOT NULL,PRIMARY KEY (`competence_id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;[/code]


2nd table is---


and i have two Entity class for them...

i have two method
one to CreateCompetence and another for createCompetencESection.

So how i can insert the value in the Refrence key Table.

Kindly give me the logic how to write function logic for
CreateCompetenceSection........
Cor Takken
Ranch Hand

Joined: May 21, 2007
Posts: 58
I think you can clarify your question even more if you can show us the code snippet showing where you persist your parent and particularly where you place the child "in" the parent... And perhaps some of the setter methods of the child, but that depends on how how link the child to the parent.


SCJP 1.5
Dolphins are grey, but they dream in colour.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How toPersist Value in the Tables Using Entity Bean
 
Similar Threads
EJB without primary key in Database
How to Determine Whether to Insert or Update
Can Foreign key be Null for some rows?
displaying parent and child images from database based on roleid
get all the records from a child table ?