-->
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: Mapping Exception while working with Inheritance
PostPosted: Tue Dec 14, 2004 1:19 pm 
Newbie

Joined: Tue Dec 14, 2004 12:54 pm
Posts: 4
Location: Bangalore, India
Hello

I am having a Base Class called Person having a primary key.

Now there is a sub class called Customer which extends Person and the Customer class having many-to-one & one-to-many relationship.

Mapping Class

<class name="HibernateDemo.Project.iJET.Customer" table="CUSTOMERX">
<id name="id" type="int" unsaved-value="0" >
<column name="id" sql-type="number(38)" not-null="true"/>
<generator class="increment"/> </id>
<property name="company_name" column="COMPANY_NAME" type="string" />

<many-to-one name="address" class="HibernateDemo.Project.iJET.Address" column="id"/>

<set name="telephone" cascade="all" inverse="true" lazy="true">
<key column="id"/>
<one-to-many class="HibernateDemo.Project.iJET.Telephone"/>

</set>

<one-to-one name="person" class="HibernateDemo.Project.iJET.Person" constrained="true" cascade="all" />
</class>

</hibernate-mapping>

Bean Class

class Customer extends Person
{

private String company_name;
private Address address;
private Set telephone;
public String getCompany_name()
{return company_name; }
.........
public Set getTelephone()
{return telephone;}
public void setTelephone(Set telephone)
{this.telephone=telephone;}


Main Class

Configuration config=new Configuration()
.addClass(Customer.class)
.addClass(Person.class)
.addClass(Telephone.class)
SessionFactory sf = config.buildSessionFactory();
Session sess = sf.openSession();
Transaction tx = null;
try {
tx = sess.beginTransaction();
Customer customer = new Customer();
customer.setName("Raj");
customer.setAge(24);
customer.setCompany_name("TurningPoint Software");
........

This is the Error

net.sf.hibernate.MappingException: Repeated column in mapping for class Hibernat
eDemo.Project.iJET.Customer should be mapped with insert="false" update="false": id at net.sf.hibernate.persister.AbstractEntityPersister.checkColumnDuplica
tion(AbstractEntityPersister.java:978)
at net.sf.hibernate.persister.NormalizedEntityPersister.<init>(Normalize
dEntityPersister.java:878)



Kindly give me the answer. Thanks for advance.


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.