-->
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: Can this happen? If yes, fantastic!
PostPosted: Fri Apr 01, 2005 5:10 am 
Senior
Senior

Joined: Sun Mar 14, 2004 10:16 am
Posts: 129
Location: Ankara
I wonder that if I can handle the below scenario via Hibernate,
if yes that would be perfect.

In standard class mapping, we set the table where that class instances will be saved to. But I have some strange need,
I dont want to give a table name in the beginning of the class mapping,
in runtime according to user selection, the table that the instances will be changed, a small example:

Class Cars {
Long id;
String type;
String model;
....

}

In gui, user create a new car and set its type say; car.setType("sport");

and then called save, what I want, is saving this data to the table "@type@Car", may exist or not (hibernate creates non-existing tables)
in that example, the generated table will be "sportCAR" and that data will be saved to that table. Since I do not know all car types, I cant map them by table per concrete class mapping strategy in the initialization of hibernate and the configuration files.

Can I do such implementaion via hibernate?

_________________
-developer


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 01, 2005 5:16 am 
Senior
Senior

Joined: Sun Mar 14, 2004 10:16 am
Posts: 129
Location: Ankara
can such a class mapping be done

class name ="CAR" table = @propert1ValueCAR@
...
...
<property name = "property1" Column = "Property1" ...

_________________
-developer


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 01, 2005 9:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
no - hibernate cant do that.


but you could probably easily implement on top of hibernate - just generate a mapping that states what you need and rebuild your Configuration/SessionFactory.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 01, 2005 10:32 am 
Regular
Regular

Joined: Thu Apr 15, 2004 1:12 pm
Posts: 55
Hi Borak,

Why do you want to use different tables for different values of your 'type' property? That is certainly novel, I imagine you must have some good reason for wanting to do that, but I don't suppose I know what the reason is, and I am curious...

—ml—


Top
 Profile  
 
 Post subject: could
PostPosted: Fri Apr 01, 2005 12:50 pm 
Beginner
Beginner

Joined: Thu Mar 03, 2005 9:19 pm
Posts: 22
One reason might be:

Class Userdata
{
long id;
String name;
Some Data Properties...
}

If each user has millions of rows (gigas of data) of UserData, it might be better to persist UserData to different tables. Each user has its own table Userdata@id. This may improve performance, I think.


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.