-->
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: org.hibernate.MappingException: Repeated column in mapping
PostPosted: Fri Sep 26, 2008 3:04 am 
Newbie

Joined: Mon Oct 15, 2007 5:05 am
Posts: 3
Hibernate Version : 3

Hi,
I am working with Hibernate and JPA. I am using annotation based configuration on the JPA entities. The problem I am facing is because of the associations I have in the entity.

My entity looks like this :

@Entity(name = "AccountType")
@Table(name = "ACCOUNT_TYPE")
public class AccountType {
private static final long serialVersionUID = 1L;
private AccountReferenceType accountReferenceType;
private String accountTypeDesc;
private String currentBalanceTypeCd;
private String arrearBalanceTypeCd;
private String extensionXml;
private UUIDAssociationKey key;

@EmbeddedId
@AttributeOverrides( {
@AttributeOverride(name = "id1", column = @Column(name = "ACCOUNT_TYPE_CD", nullable = false, insertable = false, updatable = false)),
@AttributeOverride(name = "id2", column = @Column(name = "TENANT_CD", nullable = false, insertable = false, updatable = false)) })
public UUIDAssociationKey getKey() {
return key;
}

public void setKey(UUIDAssociationKey key) {
this.key = key;
}

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
@JoinColumns( {
@JoinColumn(name = "DEFAULT_ACCOUNT_REF_TYPE_CD", nullable = false),
@JoinColumn(name = "TENANT_CD", nullable = false) })
public AccountReferenceType getAccountReferenceType() {
return accountReferenceType;
}

public void setAccountReferenceType(
AccountReferenceType accountReferenceType) {
this.accountReferenceType = accountReferenceType;
}

@Basic
@Column(name = "ACCOUNT_TYPE_DESC", nullable = false)
public String getAccountTypeDesc() {
return accountTypeDesc;
}

public void setAccountTypeDesc(String accountTypeDesc) {
this.accountTypeDesc = accountTypeDesc;
}

@Basic
@Column(name = "EXTENSION_XML")
public String getExtensionXml() {
return extensionXml;
}

public void setExtensionXml(String extensionXml) {
this.extensionXml = extensionXml;
}

@Basic
@Column(name = "ARREARS_BALANCE_TYPE_CD")
public String getArrearBalanceTypeCd() {
return arrearBalanceTypeCd;
}

public void setArrearBalanceTypeCd(String arrearBalanceTypeCd) {
this.arrearBalanceTypeCd = arrearBalanceTypeCd;
}

@Basic
@Column(name = "CURRENT_BALANCE_TYPE_CD")
public String getCurrentBalanceTypeCd() {
return currentBalanceTypeCd;
}

public void setCurrentBalanceTypeCd(String currentBalanceTypeCd) {
this.currentBalanceTypeCd = currentBalanceTypeCd;
}
private RecordStatus recordStatus;
@OneToOne(fetch = FetchType.EAGER, targetEntity = RecordStatus.class, cascade = CascadeType.MERGE)
@JoinColumns({
@JoinColumn(name="ROW_STATUS_CD", insertable = false, updatable = false),
@JoinColumn(name="TENANT_CD", insertable = false, updatable = false)
})
public RecordStatus getRecordStatus() {
return recordStatus;
}

public void setRecordStatus(RecordStatus recordStatus) {
this.recordStatus = recordStatus;
}
}


The problem I am having is because of this entity only. You can the column TENANT_CD is part of the composite key as well as part of the foreign keys (RecordStatus and AccountReferenceType). When this entiy is getting loaded at that the annotation get checked and this is the execption I am getting

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [config/applicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: org.hibernate.MappingException: Repeated column in mapping for entity: com.fairisaac.edm.falcon.account.entity.AccountType column: TENANT_CD (should be mapped with insert="false" update="false")
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1281)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:442)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:383)
at java.security.AccessController.doPrivileged(AccessController.java:197)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:354)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:394)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:753)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:386)
at org.springframework.test.AbstractSingleSpringContextTests.createApplicationContext(AbstractSingleSpringContextTests.java:243)
at org.springframework.test.AbstractSingleSpringContextTests.loadContextLocations(AbstractSingleSpringContextTests.java:212)
at org.springframework.test.AbstractSingleSpringContextTests.loadContext(AbstractSingleSpringContextTests.java:187)
at org.springframework.test.AbstractSpringContextTests.getContext(AbstractSpringContextTests.java:140)
at org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:100)
at junit.framework.TestCase.runBare(TestCase.java:132)
at

The reason I am not making accountReferenceType association as insertable = false, updatable = false because I want them insertable. I can make TENANT_CD in accountReferenceType association as insertable = false, updatable = false but hibernate doesn't allow me to give those attribute for one and not for the other.

I have only given the entity because the exception I am getting at the load time only. Let me know if some one need anything else.
Any help is highly appreciated.

Thanks


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.