-->
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: Hibernate Start-Probleme
PostPosted: Sat Oct 08, 2005 11:17 am 
Newbie

Joined: Sat Oct 08, 2005 10:15 am
Posts: 1
Location: Munich
Hi,

ich versuche mit gerade mit Hibernate anzufreunden. Die Idee ist ja ziemlich straight forward und super. Doch in der Umsetzung happert es beim ersten Anlauf.

Mittlerweile habe ich die Test-Version von Exadel Studio 3.0 auf dem Rechern (mit WTP 0.7), da hier ein breiter Hibernate Support vorhanden ist. Ich habe mich an die Introduction von Hibernate.org gehalten: http://www.hibernate.org/hib_docs/v3/re ... orial.html

Um Fehlerquellen zu reduzieren, habe ich auf das Schema "Model to Object" gewählt. Exadel erstellt ein saubere TblCampaign.hbn.xml

die TblCampaign.hbn.xml sieht wie folgt aus:
<?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 package="rickBeans">
<class name="Campaign" lazy="false" table="tblEvent2">
<id name="id" column="id">
<generator class="increment"/>
</id>
<property name="account" type="string">
<column name="account" not-null="true" length="100"/>
</property>
<property name="contact" type="string">
<column name="contact" not-null="true" length="100"/>
</property>
<property name="zip" type="string">
<column name="zip" not-null="true" length="5"/>
</property>
<property name="tel" type="string">
<column name="tel" not-null="true" length="100"/>
</property>
<property name="outcome" type="string">
<column name="outcome" not-null="true" length="100"/>
</property>
<property name="status" type="string">
<column name="status" not-null="true" length="5"/>
</property>
<property name="comment" type="string">
<column name="comment" not-null="true" length="100"/>
</property>
<property name="created" type="timestamp" column="created"/>
</class>
</hibernate-mapping>

Das Mapping über die hibernate.cfg.xml über TblCampaign.hbn.xml für durchgängig auf die Java-Class rickBeans.Campaign.java.

Der einfache Query-Befehl: List result = session.createQuery("from tblEvent2").list(); führt aber zu einer Warnung (log4j) und einer fetten Fehlermeldung:
og4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
org.hibernate.hql.ast.QuerySyntaxError: tblEvent2 is not mapped. [from tblEvent2]
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:63)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:196)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:834)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at rickBeans.CampaignManager.listCampaigns(CampaignManager.java:51)
at rickBeans.CampaignManager.main(CampaignManager.java:18)
Caused by: tblEvent2 is not mapped.
at org.hibernate.hql.ast.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:85)
at org.hibernate.hql.ast.FromElementFactory.addFromElement(FromElementFactory.java:77)
at org.hibernate.hql.ast.FromClause.addFromElement(FromClause.java:67)
at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:217)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:2830)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2719)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:513)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:371)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
... 8 more

Hatte jemand da ein ähnliche Erfahrungen gemacht ? Durch den Einsatz von Exadel und das Ableiten aus der DB-Table (mySQL mit mysql-Connector / J) sollte das doch nicht passieren. Wo ist das Problem ?

Kurz zur Projekt-Struktur:
- rickBeans.campaign:
-- CampaignManager.java
-- Campaign.java
-- Tblcampaign.hbn.xml
- rickBeans.hibernate:
-- HibernateUtil.java
- hibernate.cfg.xml
(zzgl. alle diversen Libraries, doch das managed ja Exadel)

Vielen Dank für eure Hilfe im Voraus!

Rick


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 08, 2005 12:19 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
"from Campaign"


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.