1 Reply Latest reply on Nov 8, 2006 10:23 PM by Daniel Young

    OneToOne using a formula

    Daniel Young Novice

      Hi all,

      I haven't found anything in the EJB3 spec that lets me do something like the "formula" attribute of Hibernate's <one-to-one>. Does anybody know of a way to do this?

      This stems from an I18N problem..

      I have a one to many relationship between a table A and a Messages table that stores an attribute of A for each supported locale. One thought I had was to model this as a Map collection, indexed by the locale - very nifty!

      However, in cases where we know we only want a single value (for a given locale), it seems silly to populate the whole map. So I thought a one-to-one with a formula condition would be a good idea, ala Hibernate (http://www.hibernate.org/hib_docs/v3/reference/en/html/mapping.html#mapping-declaration-onetoone).

      Currently I'm thinking about an entity callback that populates a transient attribute using the current locale, but am hoping for something nicer..

      any ideas would be much appreciated!

      PS- I realise this question is more about the EJB3 spec than JBoss' implementation, but am not sure where else to ask? :)