-->
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.  [ 10 posts ] 
Author Message
 Post subject: Can not create Hibernate querries
PostPosted: Thu Oct 27, 2005 3:20 am 
Newbie

Joined: Thu Oct 27, 2005 3:06 am
Posts: 17
Hello,

I'm completely new to Hibernate and I have big problems running the Hibernate Tools plugin. I'm using eclipse 3.1.1, and downloaded HibernateTools-3.1.0.beta1. The installation worked perfectly and the generation of all the configuration files as well worked.
(The underlying database is a MySQL 5)

Now the problem:
As soon as I switch to the Hibernate console in order to generate querries I can see my tables listed within the console tree but doing a double click on the table or any other items from the table does not generate Hibernate querries.

So I guess my database connection is configured right (because I can see my demo table) but something other is going wrong.

Can anybody help me on this issue?

Thanx in advance, Florian!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 3:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
to run queries in the beta release right click on the configuration and open the HQL Editor (or use the hql icon on the toolbar)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 4:00 am 
Newbie

Joined: Thu Oct 27, 2005 3:06 am
Posts: 17
Thanx for Your reply, but what I want to do is that I want to have query generation...I mean if there was the possibility to create querries in the former releases I'm sure there must be a possibility to do so in the Beat release, too!?

Anyway, can You post me a sample query in order ro run the query within the editor?

And can You tell me where to receive former Hibernate Tool releases which are eclipse 3.1 compliant? (I searched sourceforg etc. but could not find anything working with the eclipse 3.1...)

Thanx a lot, Florian!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 4:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
huh ? it *is* Eclipse 3.1 compliant.

double clicking only works under the Session factory nodes....but otherwise go read the documentation about querying.

All the double clicking does is to automatically generate "from <classname>" e.g. "from Order"

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 4:45 am 
Newbie

Joined: Thu Oct 27, 2005 3:06 am
Posts: 17
Ok, now we're getting closer to the problem: because I cann not see any entries within the Session factory. Any ideas how to display these?

(I want to access a simple table called 'Employers', and the files which were automatically generated are:

Employers.hbm.xml
Employers.java
EmployersHome.java
GeneralHbmSettings.hbm.xml
hibernate.cfg.xml
hibernate.reveng.xml

But no item like "Employer.class" is displayed within the Session factory...

Any clue?


Thank You very much for You immediate replies!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 4:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
what is displayed instead ?

Is there any nodes under the configuration ?

did you look in the error log ?

does your cfg.xml contain any mappings ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 5:10 am 
Newbie

Joined: Thu Oct 27, 2005 3:06 am
Posts: 17
The Session Factory is empty...as well as the Configuration; wihitn the cfg.xml there is a mapping entry.

In the error log there are two warnings which say the following:
WARN main net.sf.ehcache.config.Configurator - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: bundleresource://161/ehcache-failsafe.xml

and:
WARN Worker-8 org.hibernate.impl.SessionFactoryObjectFactory - Could not bind factory to JNDI

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getNameParser(Unknown Source)
at org.hibernate.util.NamingHelper.bind(NamingHelper.java:52)
at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:295)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1127)
at org.hibernate.console.ConsoleConfiguration$2.execute(Unknown Source)
at org.hibernate.console.execution.DefaultExecutionContext.execute(Unknown Source)
at org.hibernate.console.ConsoleConfiguration.execute(Unknown Source)
at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(Unknown Source)
at org.hibernate.eclipse.console.workbench.ConsoleConfigurationWorkbenchAdapter.getChildren(Unknown Source)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(Unknown Source)
at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:192)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76)


But these are only warnings, so I thought everything should work anyway. I also searche through this forum because of the ehcache stuff but I could find nothing useful...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 5:19 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
and that mapping entry is probably just general_something.hbm.xml which does not include anything; thus nothing were mapped.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 5:31 am 
Newbie

Joined: Thu Oct 27, 2005 3:06 am
Posts: 17
Did not get exactly what You meant by Your last post...so here is the hibernate.cfg.xml file:

<?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 name="SessionFactory">
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/demo</property>
<property name="hibernate.default_catalog">demo</property>
<property name="hibernate.default_schema">Employers</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<mapping resource="Employers.hbm.xml" />
</session-factory>
</hibernate-configuration>


and this is the corresponding Employers.hbm.xml:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!--
Auto-generated mapping file from
the hibernate.org cfg2hbm engine
-->
<class name="Employers" table="employers" catalog="demo">
<id name="id" type="integer" unsaved-value="$c2h.getUnsavedValue($property)">
<column name="ID" />
<generator class="Employers" />
</id>
<property name="firstname" type="string">
<column name="firstname" length="30" />
</property>
<property name="lastname" type="string">
<column name="lastname" length="30" />
</property>
<property name="birthdate" type="date">
<column name="birthdate" length="10" />
</property>
<property name="solutionline" type="string">
<column name="solutionline" length="50" />
</property>
<property name="username" type="string">
<column name="username" length="30" />
</property>
<property name="password" type="string">
<column name="password" length="30" />
</property>
</class>
</hibernate-mapping>

But these files seem to be correctly...so I have no clue where to search for the error.

Would be glad if You could go on with advice, thank You very much...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 5:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
with this mapping you should at least get an Employee listed under the configuration node.

_________________
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.  [ 10 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.