File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Object Relational Mapping
insert two tables in single action ?
Joined: Oct 09, 2004
Jul 18, 2006 02:55:00
i am using
i am using mssql2000 server. i have 2 tables
1. displayname (FieldID,Title)
2. MainTable (FieldID, Description)
i have one jsp. it contains title and description
i want to insert title, in the first table(displayname, see above) and
i want to insert description, in the second table(mainTable, see above)
Could you tell me the in single submission, i want to insert two databases.
How Hibernate Query looks like. thanks
Thank You<br />Edward
Joined: Jun 08, 2004
Jul 18, 2006 03:46:00
make store procedure at database side (T-sql in SQL server if I remember correctly )and call that store procedure in hibernate(should be possible I'm not aware about Hibernate)
Joined: Mar 01, 2002
Jul 19, 2006 00:55:00
for two tables say u have 2 hbm files(t1,t2) and 2
now while saving, write:
Call commit() whne u have saved objects of both classes representing ur tables.
hope it works......!!!
Joined: Jun 19, 2001
Jul 19, 2006 01:13:00
i think edward wants to insert two entries with the same FieldId ??
with your aproach hibernate will use two different IDs (unless you use "assigned" generator.
so probably you need to map the properties (Title, Description) of your class to two tables. in hibernate you use the <join> element for this.
perhaps you could also use a one-to-one relation with primary key association could do the trick if its a composition (you did not show any code...)
check the hibernate reference manual for those two things and see if they help...
I agree. Here's the link:
subject: insert two tables in single action ?
record Insertion problem
Multiple insert into database
1-to-M mapping confusion
Data transfer between tables
Three Table/Class Combination Display?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014