-->
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.  [ 2 posts ] 
Author Message
 Post subject: One Java Bean Class handle Two Table
PostPosted: Thu Apr 19, 2007 6:26 am 
Newbie

Joined: Tue Mar 27, 2007 8:49 am
Posts: 1
Hello everybody,

I have two tables which have the same structure (field names,field types, and field order as well).
The primary key values in the two tables (primary key field ID - Long data type) are unique. If in the first table has contain record with ID value 1, then the second table 100% don't have any record with ID value 1 and so vice versa. Basically, if the contents of the two tables are merged into one table, it will not violate the primary key contraint.

The question is
Can one hibernate xml file and one hibernate Java Bean class handle/retrieve records from two tables ?



My detailed other information is :

Hibernate version:3.0.5

Mapping documents:no need

Code between sessionFactory.openSession() and session.close():no need

Full stack trace of any exception that occurs:no need

Name and version of the database you are using:Firebird 2.0

The generated SQL (show_sql=true):no need

Debug level Hibernate log excerpt:no need


I would appreciate much if any one give idea about merging the two tables into one Java Bean class without losing the record order.


Thank you very much.


Regards,
Ferry


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 19, 2007 8:14 am 
Regular
Regular

Joined: Mon Mar 26, 2007 12:38 am
Posts: 119
Hi,
>>> Can one hibernate xml file and one hibernate Java Bean class handle/retrieve records from two tables ?

You will get a DuplicateMappingException if you try to map one class to two tables. Where you map ( in the same .hbm.xml file or many ) makes no difference.

>>>I would appreciate much if any one give idea about merging the two tables into one Java Bean class without losing the record order.

You can create a view on "union" of two tables. Then map entity class to this view. This allows you to get data from both tables seamlessly.

What is it that you call as record order ?

-----------------------------------------------------------
Rate the reply if you find it helpful


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.