Hi, I need some help.

I am trying to use some transient values in a OneToMany Mapping, but the
transient values are created as colums in the database.

I have a ProductBO Class, which contains a RegionType Class.

In database, i have a product_table, which has a region_id.  This is a
forign key to the region_table.  
The region_table has a composite key: region_id, locale_language,
locale_variant.  
The problem is that the product_table to map regions correctly, the
product_table should also be able to map the locale_language and
locale_variant colums.  But i cannot have these columns in the
product_table.

The way i thought i could get around this, was to store in the ProductBO
class, the localeLanaguage and localeVariant, as transient member variables.


public class ProductBo implements Serializable
{
    @Transient
    private String localLanguage;
    @Transient
    private String localeVariant;

    @ManyToOne
        @JoinColumns({
                @JoinColumn(name="region_id", referencedColumnName="region_id"),
                @JoinColumn(name="localeLanguage",
referencedColumnName="locale_language"),
                @JoinColumn(name="localeVariant",
referencedColumnName="locale_variant")
        })
        private RegionType region;



So in pseudo SQL the following should happen. Where "en" comes from the
localeLanaguge field in the ProductBo, and "cm" comes from the localeVariant
field in the ProductBo.


SELECT region
FROM product_table prod, region_table reg
WHERE prod.region_id = reg.region_id AND
region.locale_lanaguage = "en" AND
region.locale_variant = "cm"


I have tried to do that in the join above, but unsuccessfully. When i create
this database (using the Schema Export feature of hibernate), the
product_table, has two extra fields added (localeLanugage and localeVariant)
which should not be present, as they are defined as @Transient.


I think I need a line simlar to @JoinColumn(name="localeVariant",
referencedColumnName="locale_variant")  But where
referencedColumnName="locale_variant" value is gotten from
name="localeVariant" (which is a member variable of the ProductBo object).
eg if localeVariant had a value "en", then the locale_variant would use this
value.

Thanks for your help
-- 
View this message in context: 
http://www.nabble.com/Using-Transient-Values-to-map-a-ManyToOne-relationship-JPA-Hibernate-tp17643391s2369p17643391.html
Sent from the AppFuse - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to