-->
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.  [ 6 posts ] 
Author Message
 Post subject: Hibernate Tools: installtion
PostPosted: Fri Apr 13, 2007 4:58 am 
Newbie

Joined: Fri Apr 13, 2007 4:42 am
Posts: 3
Location: Belgium
Hi everybody. I've installed Hibernate Tools in Eclipse. Plugins are recognized, so no problems. But when I try to execute à copied example just to add a new record, - the below importation aren't valid:

import org.hibernate.Session;
import org.hibernate.SessionFactory;

But if i add all external jars from Hibernate Core (that is not necessary according the documentation for Hibernate Tools) everything is OK.

Could anyone help me, please?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 13, 2007 5:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
execute where ?

If in Criteria editor it should work.

Your own project should of course have the hibernate jars if you are running hibernate code in there.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Hibernate Tools installation
PostPosted: Fri Apr 13, 2007 5:40 am 
Newbie

Joined: Fri Apr 13, 2007 4:42 am
Posts: 3
Location: Belgium
First aof all - Thank you for so fast feed back.
I execute it in Eclipse.

I created a hibernate.config and console config via wizzard like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">camser</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/antiquites</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
</session-factory>
</hibernate-configuration>

This file is in the root of my project.
I created a package 'Objects' where HIbernate put generated classes Article and Category as well as corresponding Article.hbm.xml and Category.hbm.xml.

Then I created a class AddCategory in the package 'Objects' like this:

package objects;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class AddCategory
{
public static void main(String[] args)
{
Session session = null;

try
{
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session = sessionFactory.openSession();
org.hibernate.Transaction tx = session.beginTransaction();

System.out.println("Inserting Book object into database..");
Category category = new Category();
category.setCat("Category # 1");
session.save(category);
System.out.println("Book object persisted to the database.");
tx.commit();
session.flush();
session.close();
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
finally
{
}
}
}

And my importation aren't valid.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 13, 2007 5:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
as i said; your eclipse project of course need to have the hibernate jars to be able to compile your own code.

the docs just state that your should not put hibernate related jars onto the console configuration classpath since *there* they are unnecessary.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 13, 2007 5:59 am 
Newbie

Joined: Fri Apr 13, 2007 4:42 am
Posts: 3
Location: Belgium
OK, thank you and I'm sorry for my misunderstanding of the doc.

best regards,


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 15, 2007 10:29 am 
Beginner
Beginner

Joined: Wed Apr 13, 2005 12:49 pm
Posts: 34
JCrusoe wrote:
OK, thank you and I'm sorry for my misunderstanding of the doc.

best regards,


Hey JCrusoe, I had the same problem.


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