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.