-->
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.  [ 2 posts ] 
Author Message
 Post subject: Inhertance mapping woes
PostPosted: Sun Apr 22, 2007 4:02 pm 
Newbie

Joined: Sat Dec 10, 2005 4:16 am
Posts: 2
Hi guys

I am using hibernate 3.2 GA as my persistance provider with mysql 5 as my database.

I am trying to map an object model to the database model (or may be vice versa.)

I have an Loan base object with its own Loan table. Then i have an LoanOptionARM object that extends Loan object and a couple of concrete child loan objects, let show my entities.

Code:
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@Table(name="LOAN")
@DiscriminatorColumn(
    name="LOAN_PRODUCT_NAME",
    discriminatorType=DiscriminatorType.STRING
)
public class Loan implements java.io.Serializable {
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column(name="LOAN_IDENTIFIER")
    public int getId() {
        return id;
    }

   @Column(name="LOAN_PRODUCT_NAME")
    public String getLoanProductName() {
        return loanProductName;
    }
}

@Entity
@Table(name="LOAN_OPTION_ARM")
public abstract class LoanOptionARM
        extends Loan
        implements java.io.Serializable {
}

@Entity
@Table(name="LOAN_OPTION_ARM")
@DiscriminatorValue(value="CF2L")
public class LoanOptionARMCF2L extends LoanOptionARM {
}


i have left the rest of the code in the entities for obvious reasons. The problem that I am facing is that hibernate is generating an extra insert query for Loan_Option_Arm table as I can see in the hibernate log.

Code:
Hibernate: insert into LOAN (LOAN_PRODUCT_TYPE_ID, LOAN_PRODUCT_NAME) values (?, ?)
Hibernate: insert into LOAN_OPTION_ARM (colmuns) values (values)
Hibernate: insert into LOAN_OPTION_ARM (LOAN_IDENTIFIER) values (?)


The second query inserts the LOAN_OPTION_ARM data correctly but I have no idea why the third query for LOAN_OPTION_ARM is being generated.

Please help me out here.[/code]


Top
 Profile  
 
 Post subject: Inhertance mapping woes
PostPosted: Tue Apr 24, 2007 7:46 am 
Newbie

Joined: Sat Dec 10, 2005 4:16 am
Posts: 2
Any one??


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

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.