-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Generified Associations are not supported by hibernate?
PostPosted: Tue Aug 29, 2006 9:33 am 
Senior
Senior

Joined: Sat Nov 27, 2004 4:13 am
Posts: 137
Hibernate version: Hibernate 3.2 RC2
Hibernate annotations version: Hibernate Annotations RC1


Code:
@Entity
@Table(schema = "cmn", name = "tb_lookup")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "fk_lkt", discriminatorType = DiscriminatorType.STRING)
@SequenceGenerator(name = SimpleDomainObject.SEQUENCE_ALIAS, allocationSize = 1, sequenceName = "cmn.sq_lookup")
public abstract class Lookup extends SimpleDomainObject {
    @Id
    private Long id;

    @Column(name = "title")
    private String title;

    ...
}


Code:
@Entity
@DiscriminatorValue("account-type")
public class AccountType extends Lookup {
}


and

Code:
@MappedSuperclass
public abstract class LookupAware<L extends Lookup> {
    @Id
    private Long id;

    @ManyToOne
    @JoinColumn("fk_lookup")
    private L lookup;
    ....
}


Code:
@Entity
@Table(name="accountTypeAware")
public class AccountTypeAware extends LookupAware<AccountType > {
    @Column("name")
    private String name;
...
}


Well, in hibernate startup an exception occures:

so it seems that hibernate uses introspection for determining the property types!

I've changed

Code:
@MappedSuperclass
public abstract class LookupAware<L extends Lookup> {
    @Id
    private Long id;

    public abstract L getLookup();

    public abstract void setLookup(L lookup);
    ....
}


Code:
@Entity
@Table(name="agentTypeAware")
public class AccountTypeAware extends LookupAware<AccountType> {
    @ManyToOne(targetEntity = AccountType.class)
    @JoinColumn("fk_lookup")
    private AccountTypelookup;

    @Column("rate")
    private Double rate;

    public AccountTypegetLookup() {
       return lookup;
    }

    public void setLookup(AccountTypelookup) {
       this.lookup = lookup;
    }
...
}


Still same exception happens on hibernate startup! But When I read property types in second solution, the property types are not Lookup and are of its child type!

How can I handle this?

_________________
don't forget to credit!

Amir Pashazadeh
Payeshgaran MT
پايشگران مديريت طرح
http://www.payeshgaran.co
http://www.payeshgaran.org
http://www.payeshgaran.net


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.