-->
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.  [ 5 posts ] 
Author Message
 Post subject: More complex than basic mappings..
PostPosted: Thu Dec 01, 2005 5:37 am 
Newbie

Joined: Thu Dec 01, 2005 5:25 am
Posts: 3
Hi all Hibernate gurus,

I'd like to know if I missed something trivial...

Saying 2 tables A and B
A with 10 columns a1,a2,a3,a4,a5,a6,a6,a7,a8,a9,a10
B with 5 columns b1,b2,b3,b4,b5

I would like to map join from these 2 tables as 1 class
with fields :
a1,a2,a6 & b1, b5 ?

I can't figure a way to do it in HQL isn't it ?
I wondered about about using SQL native to fetch the rowset & convert it an object but hibernate documentation doesn't refer to this usage at all..

So what kind of solution would you use in such case ?
I'd like to avoid to map 2 tables into classes before filling my class with right data... (this is reference data so I don't worry about about persistence just reading it)..

Plain old JDBC could be my friend.

thanks for your help.
------
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

[b]Hibernate version:[/b]
Hibernate 3.0.x
[b]Mapping documents:[/b]
not yet available
[b]Code between sessionFactory.openSession() and session.close():[/b]
no code yet
[b]Full stack trace of any exception that occurs:[/b]
no exception
[b]Name and version of the database you are using:[/b]
Sybase 12.5
[b]The generated SQL (show_sql=true):[/b]

[b]Debug level Hibernate log excerpt:[/b]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 6:02 am 
Newbie

Joined: Tue Nov 22, 2005 10:08 am
Posts: 17
You can do 3 types of mappings:
1. table per class
2. table per hierarchy
3. table per subclass

What is the relation between your tables?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 6:03 am 
Newbie

Joined: Mon Nov 28, 2005 2:35 pm
Posts: 14
We tried something similiar using a view.
Since the HibernateTools support mapping of views you can even let your your mapping file and .java file be generated automatically.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 6:18 am 
Newbie

Joined: Thu Dec 01, 2005 5:25 am
Posts: 3
Thanks foster for your answer..
I imagined such solution but we have many constraints before going in production so we would have dreamed to avoid views but the door is still open if its the only way to avoid DTO or other stuff!!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 11:06 am 
Newbie

Joined: Thu Dec 01, 2005 5:25 am
Posts: 3
I've just put this solution in action but encountered several problems:
- tables on sybase where created in a strange way so Hibernate can't guess the field used a primary then generate 2 classes MyTable (witha signe column =id= & MyTableId (with all columns from the view)
- find(from MyClass) fills a list with the good number of items but fills it with a huge number of null values !!!

I think I will be obliged to use another strategy (DTO e.g)

Any other valuable idea ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.