Announcement Announcement Module
Collapse
No announcement yet.
Repeated column in mapping for entity: xxx.xxx.JsyDepartment column: id Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Repeated column in mapping for entity: xxx.xxx.JsyDepartment column: id

    Hi,

    i got the following error when i deploy it to Tc Server
    Code:
    Mar 30, 2011 10:53:52 AM org.apache.catalina.core.ApplicationContext log
    INFO: Initializing Spring root WebApplicationContext
    2011-03-30 10:53:58,384 [main] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in file [D:\IDE\springsource\tc-server-developer-2.1.1.RELEASE\spring-insight-instance\wtpwebapps\JsyMoneyApp1\WEB-INF\classes\META-INF\spring\applicationContext.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in file [D:\IDE\springsource\tc-server-developer-2.1.1.RELEASE\spring-insight-instance\wtpwebapps\JsyMoneyApp1\WEB-INF\classes\META-INF\spring\applicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: persistenceUnit] Unable to build EntityManagerFactory
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
    	...
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in file [D:\IDE\springsource\tc-server-developer-2.1.1.RELEASE\spring-insight-instance\wtpwebapps\JsyMoneyApp1\WEB-INF\classes\META-INF\spring\applicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: persistenceUnit] Unable to build EntityManagerFactory
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    	... 
    Caused by: javax.persistence.PersistenceException: [PersistenceUnit: persistenceUnit] Unable to build EntityManagerFactory
    	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:911)
    	at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
    	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
    	... 
    Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: com.jeppy.moneyapp.domain.JsyDepartment column: id (should be mapped with insert="false" update="false")
    	at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:676)
    	at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:698)
    	at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:720)
    	at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:474)
    	at org.hibernate.mapping.RootClass.validate(RootClass.java:235)
    	at org.hibernate.cfg.Configuration.validate(Configuration.java:1332)
    	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1835)
    	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:902)
    	...
    this are steps to reproduce the error:

    Code:
    // Spring Roo 1.1.2.RELEASE [rev fbc33bb] log opened at 2011-03-30 10:24:53
    project --topLevelPackage com.jeppy.moneyapp --projectName JsyMoneyApp1 --java 6
    // Spring Roo 1.1.2.RELEASE [rev fbc33bb] log closed at 2011-03-30 10:24:56
    // Spring Roo 1.1.2.RELEASE [rev fbc33bb] log opened at 2011-03-30 10:25:03
    persistence setup --provider HIBERNATE --database MYSQL --hostName 127.0.0.1 --databaseName mydb --userName roo --password spring
    entity --class ~.domain.JsyDepartment --testAutomatically
    field number --fieldName departmentId --type java.lang.Integer --column id
    field string --fieldName name --column name --sizeMin 1 --sizeMax 100
    field string --fieldName description --column description --sizeMin 1 --sizeMax 255
    field number --fieldName activeStatus --type short --column activestatus
    field date --fieldName addedDate --type java.util.Date --dateFormat MEDIUM --dateTimeFormatPattern "dd/MM/yyyy hh:mm:ss" --column adddt --timeFormat MEDIUM
    field number --fieldName addedBy --type java.lang.Long --column addby
    field date --fieldName changedDate --type java.util.Date --dateFormat MEDIUM --dateTimeFormatPattern "dd/MM/yyyy hh:mm:ss" --column changedt --timeFormat MEDIUM
    field number --fieldName changedBy --type java.lang.Long --column changeby
    controller all --package ~.controller
    security setup
    perform package
    When i check the JsyDepartment class, seems ok with the following code
    Code:
    @RooJavaBean
    @RooToString
    @RooEntity
    public class JsyDepartment {
    
        @Column(name = "id")
        private Integer departmentId;
    
        @Column(name = "name")
        @Size(min = 1, max = 100)
        private String name;
    
        @Column(name = "description")
        @Size(min = 1, max = 255)
        private String description;
    But when i go to JsyDepartment_Roo_Entity class, seems the generated code are

    Code:
    declare @type: JsyDepartment: @Entity;
        
        @PersistenceContext
        transient EntityManager JsyDepartment.entityManager;
        
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        @Column(name = "id")
        private Long JsyDepartment.id;
        
        @Version
        @Column(name = "version")
        private Integer JsyDepartment.version;
    Any idea how to fix it?

    Btw: sorry for my bad English grammar, my mother tongue not English.

    Thanks.

    Jeppy

  • #2
    You already have a column called "id" associated with field departmentId, and Roo by default has created an @Id field in the entity ITD with the same column name.

    You can either:
    1. add insertable = "false" and updatable = "false" to the Column annotation for departmentId, or
    2. change the column name of departmentId, or
    3. change the column name of your @Id field by adding the identifierField attribute to @RooEntity, eg
      Code:
      @RooEntity(identifierField = "jsyDepartmentId")
    Last edited by Alan Stewart; Mar 30th, 2011, 04:45 AM.

    Comment


    • #3
      Hi Alan,

      Thanks.. your advice has solved my issue

      Regards,

      Jeppy Suparto

      Comment

      Working...
      X