-->
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: HibernateException: Missing column:
PostPosted: Sun Mar 22, 2009 7:39 pm 
Newbie

Joined: Sun Mar 22, 2009 7:23 pm
Posts: 2
Hi Everyone. I am trying to move a small web-application I am working to mySQL (from the memory) test database.

I am using JBoss Seam web-framework. My persistable entities are using annotations. I am using the latest mySQL connector library from the mySQL website.

I am very new to Hibernate, but I did some reading and could not quite find any answers to the exact problem I am getting. When i attempt to start my web-container (JBoss Application Server) I get the following exception:

Quote:
Caused by: org.hibernate.HibernateException: Missing column: id in project.user
at org.hibernate.mapping.Table.validateColumns(Table.java:277)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1116)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:139)


Now, the natural first question is "do you have a column "id" in the user table?".. The answer is yes! :o).. This is what is really getting to me. I have even tried different datatypes (INTEGER, BIGINT) and have dropped and re-created the user table.

I am using annotations; from my User.class:

Code:
   private long id = -1;

   @Id
   @GeneratedValue
   public long getId()
   {
      return id;
   }

   public void setId(long id)
   {
      this.id = id;
   }


Here is my persistence.xml:

Code:
<persistence-unit name="userDatabase" transaction-type="JTA">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <jta-data-source>java:/myDatasource</jta-data-source>
      <properties>
         <property name="hibernate.hbm2ddl.auto" value="validate"/>
         <property name="hibernate.jdbc.batch_size" value="20"/>
         <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
      </properties>
   </persistence-unit>



my *-ds.xml file:

Code:
<datasources>
   <local-tx-datasource>
      <jndi-name>myDatasource</jndi-name>
      <connection-url>jdbc:mysql://localhost:3306/project</connection-url>
      <driver-class>com.mysql.jdbc.Driver</driver-class>
      <user-name>***</user-name>
      <password>*****</password>
   </local-tx-datasource>
</datasources>


Does anyone have any ideas why it could be not seeing this column? Any help would be greatly appreciated!!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 22, 2009 9:20 pm 
Newbie

Joined: Sun Mar 22, 2009 7:23 pm
Posts: 2
Hi Everyone, I think I figured it out.

When I changed my user/password to use the mySQL root user rather than a created user, it worked.

It may have been a permissions thing with the user I was trying to use.

Thanks!


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.