aspose file tools*
The moose likes Object Relational Mapping and the fly likes Parent-Child Relationship Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Parent-Child Relationship Problem" Watch "Parent-Child Relationship Problem" New topic
Author

Parent-Child Relationship Problem

vipul bondugula
Ranch Hand

Joined: Oct 14, 2010
Posts: 218
Hi,

I am a newbie to Hibernate. I am working on one-to-many relationship in hibernate.

I am having 2 tables. Course & Enquiry tables.

Course ===> Parent Table(M_COM_ENQRY_COURSE)
Enquiry====> Child Table(M_COM_ENQRY_FORM)

Parent Table:- M_COM_ENQRY_COURSE

CRSENQRY_N_ID
CRSENQRY_VC_CRSNM
CRSENQRY_C_STS


This table is reference by child table.

Child TAble:- M_COM_ENQRY_FORM

ENQFORM_N_ID
ENQFORM_VC_NM
ENQFORM_CRSENQRY_N_ID refers CRSENQRY_N_ID in parent table


and more columns are there but not required.


This is the design.

According to that my hibernate mapping files are:











POJO Class code:









Note:- M_COM_ENQRY_COURSE already consists of data..Acutally, M_COM_ENQRY_COURSE is the master table.

Requirement:-- I don't want to insert into that M_COM_ENQRY_COURSE(parent) table. I want to insert into only M_COM_ENQRY_FORM(child) table...

while inserting into child , just refer to parent table whether the data is existing or not..

Doubt:-- According to my requirement, is this my configuration is correct (or) not?


According to your response, i'll come up with my other Exception in this scenario..

Please anybody help..

Thanks
Vipul Kumar.


Thanks
Vipul Kumar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Parent-Child Relationship Problem
 
Similar Threads
Not able to get mapped object Set in hibernate
what changes should i made in save method in one-to-many relationships
org.hibernate.exception.SQLGrammarException: could not insert: [com.Course]
Hibernate Configuration Loading Problem
StaleStateException