-->
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.  [ 5 posts ] 
Author Message
 Post subject: Reverse engineering a DB, generated mapping produces error
PostPosted: Fri May 18, 2007 9:38 am 
Newbie

Joined: Thu May 17, 2007 4:40 pm
Posts: 2
I am using Hibernate 3.2, and am trying to reverse engineer a Postgresql (version 8.0.6) DB. The DB has a handful of tables that reference other tables. For example, the table named "agent" makes a reference to another table named "location" using the following syntax:

CONSTRAINT agent_location_fkey FOREIGN KEY ("location")
REFERENCES "location" (id) MATCH SIMPLE
ON UPDATE RESTRICT ON DELETE RESTRICT

The mapping looks like:
<many-to-one name="location" class="Location" fetch="select">
<column name="location">
</column>
</many-to-one>

My very simple Java test program simply tries to create a session:

Session session = HibernateUtil.currentSession();

I get the error below which I can't find trouble shooting info on. Does anyone have any ideas/suggestions?

[java] INFO: Mapping collection: Location.agents -> agent
[java] Exception in thread "main" java.lang.ExceptionInInitializerError
[java] at HibernateUtil.<clinit>(Unknown Source)
[java] at Test.main(Unknown Source)
[java] Caused by: org.hibernate.MappingException: Could not determine type for: String, for columns: [org.hibernate.mapping.Column(version)]


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 18, 2007 10:52 am 
Beginner
Beginner

Joined: Fri May 18, 2007 10:28 am
Posts: 48
Location: Madison, WI
Are there any static methods that you have, problem might be that those methods are having some problems initializing.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 18, 2007 11:39 am 
Newbie

Joined: Thu May 17, 2007 4:40 pm
Posts: 2
public class Test {

public static void main(String[] args) {

Session session = HibernateUtil.currentSession();
session.close();
}
}

import net.sf.ehcache.hibernate.*;
import org.hibernate.cfg.*;
import org.hibernate.*;
public class HibernateUtil {

private static final SessionFactory sessionFactory;

static {
try {
// Create the SessionFactory
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
}

public static final ThreadLocal session = new ThreadLocal();

public static Session currentSession() throws HibernateException {
Session s = (Session) session.get();
// Open a new Session, if this Thread has none yet
if (s == null) {
s = sessionFactory.openSession();
session.set(s);
}
return s;
}

public static void closeSession() throws HibernateException {
Session s = (Session) session.get();
session.set(null);
if (s != null)
s.close();
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 18, 2007 12:16 pm 
Beginner
Beginner

Joined: Fri May 18, 2007 10:28 am
Posts: 48
Location: Madison, WI
Where is ur hibernate.cfg.xml file in.
[quote]new Configuration().configure().buildSessionFactory(); [/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 20, 2007 2:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the error is about a column named version, but your mapping is about location...

and please post tool related questions in the tool forum.

_________________
Max
Don't forget to rate


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