Forums Register Login

special hibernate mapping

+Pie Number of slices to send: Send
Hi,

I have a special case of data model, which is the following:
1- I have a table where my entities, i.e table names are stored:
CREATE TABLE [Entity_tbl]
( [id] [INT] NOT NULL , -- (PK)
[name] [NVARCHAR] NOT NULL
)

2- I have a table where I store values, which it's used by
any entity, for instance [Status] value
CREATE TABLE [Status_tbl]
( [id] [INT] NOT NULL , -- (PK)
[name] [NVARCHAR] NOT NULL
)

3- I have a table where I store values assigned to a specific
entity instance:
CREATE TABLE [Entity_Status_tbl]
( [entity_id] [INT] NOT NULL, -- (FK = [Entity_tbl].[id])
[instance_id] [INT] NOT NULL, --
[status_id] [INT] NOT NULL -- (FK = [Status_tbl].[id])
)
4- I have others tables which are considered as entities which
they handle the instances, for example a concrete entities
[Service], [Resource]
CREATE TABLE [Service_tbl]
( [id] [INT] NOT NULL , -- (PK)
[name] [NVARCHAR] NOT NULL
)

CREATE TABLE [Resource_tbl]
( [id] [INT] NOT NULL , -- (PK)
[name] [NVARCHAR] NOT NULL,
)

Having this model, I can assign a status value to any service or resource created instance, without changing [Service_tbl] and [Resource_tbl] schema.

In fact, the references (one-to-one or one-to-many) between [Service_tbl], [Resource_tbl] and [Entity_Status_tbl] could be described as following:
[Service_tbl].[id] = [Entity_Status_tbl].[instance_id]
AND
[Entity_Status_tbl].[entity_id] = id of the entity service stored
in [Entity_tbl]

[Resource_tbl].[id] = [Entity_Status_tbl].[instance_id]
AND
[Entity_Status_tbl].[entity_id] = id of the entity resource stored
in [Entity_tbl]

MY QUESTION: How I exprime these references?

THANKS A LOT.
[ February 08, 2005: Message edited by: Djamel Djemaoun ]
+Pie Number of slices to send: Send
Not sure what you're asking. Do you want to map the schema you describe using Hibernate?
+Pie Number of slices to send: Send
 

Originally posted by Loren Rosen:
Not sure what you're asking. Do you want to map the schema you describe using Hibernate?



--------------------------------------------------------------------------


Thanks Loren for your reply.

Ya, I want to map the schema knowing the table [Entity_Status_tbl] is kepting to references:
- one to the entity willing to support [Status]
- other to the entity instance specifing a value of [Status].

I want to have the comportment:
1- [Entity_Status_tbl] referes to [Service_tbl] when [entity_id] = to [Entity_tbl].[id] (already known value, let say 75).
2- [Entity_Status_tbl] referes to [Resource_tbl] when [entity_id] = to [Entity_tbl].[id] (already known value, let say 25).
3- All this info will be stored in XML mappings

I hope my additional info could help you to help me.

Best Regards.
I'm just a poor boy, I need no sympathy, because I'm easy come, easy go, little high, little low, little ad
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1306 times.
Similar Threads
Answers of Sun's Free Proficiency Assessment
hibernate table per class hirearchy discriminator value with query
Best mapping approach for reference/LOV/lookup data
An example of denormalization
CMR Relations one-to-many
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:52:10.