-->
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.  [ 3 posts ] 
Author Message
 Post subject: Simple @ManyToOne, why "Could not determine type"?
PostPosted: Wed Mar 24, 2010 11:17 pm 
Newbie

Joined: Wed Feb 18, 2009 5:07 am
Posts: 8
I have searched quite a lot of forums and threads, Hibernate & Spring MVC. But still cannot figure out why I am encounter this exception when starting my app:
Code:
Caused by: org.hibernate.MappingException: Could not determine type for: com.xxx.Organization, at table: usr, for columns: [org.hibernate.mapping.Column(org)]
   at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:292)
   at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:276)
   at org.hibernate.mapping.Property.isValid(Property.java:207)
   at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:458)
   at org.hibernate.mapping.RootClass.validate(RootClass.java:215)
   at org.hibernate.cfg.Configuration.validate(Configuration.java:1149)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1334)
   at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
   at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:855)
   at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:774)
   at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1400)


My source for User.java is:
Code:
@Entity
@Table(name="usr")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class User extends TimestampedPersistentObject {
   private String orgCode;
   private String loginId;
   private String password;
   private Organization org;

   @Column(name="org_code")
   public String getOrgCode() {
      return orgCode;
   }
   public void setOrgCode(final String orgCode) {
      this.orgCode = orgCode;
   }

   @Column
   public String getLoginId() {
      return loginId;
   }
   public void setLoginId(final String loginId) {
      this.loginId = loginId;
   }

   @Column
   public String getPassword() {
      return password;
   }
   public void setPassword(final String password) {
      this.password = password;
   }

   @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
    @JoinColumn(name = "org_id")
   public Organization getOrg() {
        return org;
    }
    public void setOrg(Organization org) {
        this.org = org;
    }
}


Source of Organization.java:
Code:
@Entity
@Table(name="organization")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Organization extends TimestampedPersistentObject {
    private String code;
    private String name;

    @Column
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
   
    @Column
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}


In my TimestampedPersistentObject.java:
Code:
@MappedSuperclass
public class TimestampedPersistentObject implements PersistentObject {
    @Id
    private String id;
    @Version
    private int version;
    /**
     * Returns a generated GUID
     */
    public String getId() {
        return GUIDGenerator.getInstance().getGUID();
    }

    /**
     * @see com.ks.gwm.pojo.PersistentObject#getVersion()
     */
    public int getVersion() {
        return version;
    }
}


Can anyone tell me where I am going wrong? Or the problem is caused by Spring MVC setting?
Code:
   <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
         p:dataSource-ref="dataSource">
      <property name="hibernateProperties">
         <props>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
            <prop key="hibernate.generate_statistics">${hibernate.generate_statistics}</prop>
                <prop key="hibernate.use_outer_join">true</prop>
                <prop key="hibernate.default_lazy">true</prop>
                <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
                <prop key="hibernate.cache.use_query_cache">true</prop>
                <prop key="hibernate.cache.use_second_level_cache">true</prop>
         </props>
      </property>
        <property name="packagesToScan">
          <list>
              <value>com.xxx.**.*</value>
          </list>
      </property>
   </bean>


Top
 Profile  
 
 Post subject: Re: Simple @ManyToOne, why "Could not determine type"?
PostPosted: Thu Mar 25, 2010 5:08 am 
Newbie

Joined: Wed Feb 18, 2009 5:07 am
Posts: 8
No one has any idea on this problem?


Top
 Profile  
 
 Post subject: Re: Simple @ManyToOne, why "Could not determine type"?
PostPosted: Thu Mar 25, 2010 9:58 am 
Newbie

Joined: Wed Feb 18, 2009 5:07 am
Posts: 8
Just FYI, the problem is solved after I add the setter of id and version to TimestampedPersistentObject. I don't know how can I miss that.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.