Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.2.2. GA
Mapping documents:
package com.edg.telebet.common.transport;
import com.edg.telebet.common.TelebetSettings;
import javax.persistence.*;
@Entity
@Table (name="languagestring")
public class LanguageString extends TelebetSettings implements java.io.Serializable{
//public static final long serialVersionUID = 15L;
public LanguageString() {
}
public LanguageString(Long stringValuesId, Long languageId,String stringValue){
this.stringValue = stringValue;
this.languageId = languageId;
this.stringValuesId = stringValuesId;
}
public Long stringValuesId;
public Long languageId;
public String stringValue;
public Long getStringValuesId() {
return stringValuesId;
}
public void setStringValuesId(Long stringValuesId) {
this.stringValuesId = stringValuesId;
}
public void setLanguageId(Long languageId) {
this.languageId = languageId;
}
public Long getLanguageId() {
return languageId;
}
public void setStringValue(String stringValue) {
this.stringValue = stringValue;
}
public String getStringValue() {
return stringValue;
}
public String toString() {
return stringValue;
}
}
Code between sessionFactory.openSession() and session.close():
InitialContext ctx = null;
try {
ctx = new InitialContext();
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
SessionFactory factory = null;
try {
factory = (SessionFactory)
ctx.lookup("java:/hibernate/SessionFactory");
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Session hsession = factory.openSession();
hsession.getTransaction().begin();
int sizeOfList = hsession.createQuery("from languagestring ls").list().size();
TLog.logConsole("LanguageString has "+ sizeOfList +" elements.");
Full stack trace of any exception that occurs:
17:43:57,108 ERROR [Scheduler$Listener] Handling a Scheduler call failed
org.hibernate.hql.ast.QuerySyntaxException: languagestring is not mapped [from languagestring ls]
at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:158)
at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:87)
at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)
at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:267)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3049)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2938)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:227)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:159)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:110)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1612)
at com.edg.telebet.cs.server.StartCSServer.perform(StartCSServer.java:143) << CLASS THAT CALLS HIBERNATE
at org.jboss.varia.scheduler.Scheduler$Listener.handleNotification(Scheduler.java:1235)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.mx.notification.NotificationListenerProxy.invoke(NotificationListenerProxy.java:153)
at $Proxy10.handleNotification(Unknown Source)
at javax.management.NotificationBroadcasterSupport.handleNotification(NotificationBroadcasterSupport.java:257)
at javax.management.NotificationBroadcasterSupport$SendNotifJob.run(NotificationBroadcasterSupport.java:322)
at javax.management.NotificationBroadcasterSupport$1.execute(NotificationBroadcasterSupport.java:307)
at javax.management.NotificationBroadcasterSupport.sendNotification(NotificationBroadcasterSupport.java:229)
at javax.management.timer.Timer.sendNotification(Timer.java:1234)
at javax.management.timer.Timer.notifyAlarmClock(Timer.java:1203)
at javax.management.timer.TimerAlarmClock.run(Timer.java:1286)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
Name and version of the database you are using:
RDBMS: Oracle, version: Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
The generated SQL (show_sql=true): don't have
Debug level Hibernate log excerpt: don't have
MBean configuration:
<mbean code="org.jboss.hibernate.jmx.Hibernate"
name="jboss.har:service=Hibernate">
<depends>jboss:service=Naming</depends>
<depends>jboss:service=TransactionManager</depends>
<depends>jboss.jca:service=DataSourceBinding,name=OracleDS</depends>
<depends>jboss.cache:service=TreeCache</depends>
<attribute name="DatasourceName">java:OracleDS</attribute>
<attribute name="Username">******</attribute>
<attribute name="Password">******</attribute>
<attribute name="Dialect">org.hibernate.dialect.Oracle9Dialect</attribute>
<attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>
<attribute name="CacheProviderClass">org.jboss.hibernate.cache.DeployedTreeCacheProvider</attribute>
<attribute name="DeployedTreeCacheObjectName">jboss.cache:service=TreeCache</attribute>
<attribute name="ShowSqlEnabled">true</attribute>
</mbean>
Problems with Session and transaction handling?
Yes
Is there any possible way of mapping existing class in Hibernate, and not using HAR files under JBOSS deploy folder and how? This error always occurs when I tried to use "mapped" class LanguageString (event when I used explicit settings for TABLE and COLUMN).
Thank you for your answers.
Drazen Krsmanovic
Read this:
http://hibernate.org/42.html