-->
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: mapping type problem with the ID
PostPosted: Tue Feb 28, 2006 3:51 am 
Newbie

Joined: Mon Feb 27, 2006 8:25 am
Posts: 3
Hi

I am new to hibernate so my question is probably not that interesting. Anyway I couldn't find a solution to my problem in the forum.

My table in the DB uses a own column with automatically assigned GUIDS.
I tried following but it doesn't work.

Thank you very much

the greenhorn

Code:
Initial SessionFactory creation failed.org.hibernate.MappingException: Could not determine type for: guid, for columns: [org.hibernate.mapping.Column(GUIDModulID)]
Exception in thread "main" java.lang.ExceptionInInitializerError
   at util.HibernateUtil.<clinit>(HibernateUtil.java:17)
   at verwaltung.Modulmanager.createModul(Modulmanager.java:32)
   at verwaltung.Modulmanager.main(Modulmanager.java:17)
Caused by: org.hibernate.MappingException: Could not determine type for: guid, for columns: [org.hibernate.mapping.Column(GUIDModulID)]
   at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
   at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
   at org.hibernate.mapping.RootClass.validate(RootClass.java:193)
   at org.hibernate.cfg.Configuration.validate(Configuration.java:982)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1146)
   at util.HibernateUtil.<clinit>(HibernateUtil.java:13)
   ... 2 more



Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
   <class name="verwaltung.Modul" table="Modul">
      <id name="id" column="GUIDModulID" >
         <generator class="guid"></generator>
      </id>
      <property name="Name"> <column name="ModulBezeichnung"></column></property>
   </class>
</hibernate-mapping>


Code:
package verwaltung;
import org.hibernate.id.GUIDGenerator;

public class Modul {

   private GUIDGenerator id;
   
   private String fName;
   
   public Modul(){}

   public String getName() {
      return fName;
   }

   public void setName(String name) {
      fName = name;
   }

   public GUIDGenerator getId() {
      return id;
   }

   private void setId(GUIDGenerator id) {
      this.id = id;
   };
   
}


Top
 Profile  
 
 Post subject: guid
PostPosted: Tue Feb 28, 2006 5:53 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Should be String id, not that GUIDGenerator

String id;

public String getId(){ return id;}
public void setId(String v ){ id = v;}

http://www.hibernate.org/hib_docs/v3/re ... -generator

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 28, 2006 6:00 pm 
Newbie

Joined: Mon Feb 27, 2006 8:25 am
Posts: 3
Thank you very much. It works now.


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.