-->
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.  [ 3 posts ] 
Author Message
 Post subject: Help on mapping an associated table to a (Hash)Map
PostPosted: Wed Aug 31, 2005 7:33 am 
Newbie

Joined: Wed Aug 31, 2005 6:49 am
Posts: 2
Hibernate version: 3.0.5

Name and version of the database: MySql 4.1.10a / Oracle 9i



I am trying to use a database scheme which is maintained by a third-party application. therefore I cannot change the scheme in any way - besides creating custom views.

there are two tables "Tickets" and "TicketsCustomFields". both tables are used to describe an object "ticket". the "Tickets" table contains general information like the customer, ticket description, contact details and assignment information. I managed to map this table without a problem.
the two tables have a one-to-one association meaning for every row in "Tickets" there is a row in "TicketsCustomFields" with a common primary key value.

now the second table "TicketsCustomFields" is like an extension to "Tickets" providing additional information which are specific to different kinds of tickets.
(column names here are like "customText1", "customText2", "customNumber99" etc.)

what I want to achieve is sort of combining these two tables for use with my tickets object. one way would be the use of the join-tag in the hibernate mapping file. but this would mean that I have to add numerous fields to my tickets object. - I actually do not want to do this.

instead I would like to have a field "ticketobject.allCustomFields" of type (Hash)Map. the keys into the map should be the column names and the values should be the value of the respective table-column, this way I could do things like:

Code:
ticketobject.allCustomFields.put("customText1", "Hello");
ticketobject.allCustomFields.put("customText2", "World");
ticketobject.allCustomFields.put("customNumber99", 99);


of course, I do not expect hibernate to dynamically add columns to the table. I just want to use the columns that are already available in the table.

so, do you know of a use-case for the hibernate-tags map/set/bag or whatever else I could use to realize this? or can this be done only with a UserCollectionType? if so, are there any resources on how to implement a UserCollectionType? any hints would be greatly appreciated.

thnx in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 31, 2005 9:53 am 
Regular
Regular

Joined: Thu Dec 02, 2004 7:11 am
Posts: 85
You can use dynamic-component or dynamic class


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 31, 2005 12:02 pm 
Newbie

Joined: Wed Aug 31, 2005 6:49 am
Posts: 2
thanks for this hint.

looks like this is pretty much what I was looking for.
(though I would prefer a way without the need of specifying every single column - but I suppose that's not what hibernate was designed for)


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