tags:

views:

44

answers:

2

Hi,

first of all, i apologize for such a question. I'm trying to find a solution for an architectural error (i'm not the architect :P )

Is there the possibility to have two mappings for the same table in Hibernate3? The first one would have some lazy attributes set to true. The second mapping would ha some lazy attributes set to false; besides, mappings are equals. I know, it is a strange and bizarre behaviour, but the customer asks for a quick solution.

Thanks in advance and have a happy new year.

Esteve

A: 

The very quick solution would be to have 2 different classes mapped to the same table.

RichN
+1  A: 

In theory, there's no reason why not, but you should be careful. The hibernate cache (session and L2 caches) will treat them as distinct, so if you manipulate the table row using both mappings in the same session, you run the risk of data loss, since hibernate won't know they're referring to the same underlying data.

skaffman