Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.0
Mapping documents:
===========
hibernate.cfg.xml :
----------------------
<?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.url">jdbc:mysql://localhost:3306/babadmin</property>
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.show_sql">true</property>
<mapping resource="hibernate/test/Vacation.hbm.xml"/>
</session-factory>
</hibernate-configuration>
===========
===========
Vacation.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="hibernate.test.Vacation" table="vacation"
catalog="babadmin">
<id name="VacationId" type="java.lang.Integer">
<column name="vacationId" length="11" not-null="true"
unique="true" sql-type="int" />
<generator class="assigned" />
</id>
<property name="StartDate" type="java.util.Date">
<column name="startDate" length="10" not-null="true"
sql-type="date" />
</property>
<property name="EndDate" type="java.util.Date">
<column name="endDate" length="10" not-null="true"
sql-type="date" />
</property>
<property name="Year" type="java.lang.Integer">
<column name="year" length="11" not-null="true"
sql-type="int" />
</property>
<property name="Type" type="java.lang.String">
<column name="type" length="100" not-null="true"
sql-type="varchar" />
</property>
<property name="Kei" type="java.lang.String">
<column name="kei" length="100" not-null="true"
sql-type="varchar" />
</property>
</class>
</hibernate-mapping>
===========
Code between sessionFactory.openSession() and session.close():
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
try
{
List list = session.createQuery("from Vacation").list();
Iterator it = list.iterator();
while(it.hasNext())
{
Speciality speciality = (Speciality)it.next();
System.out.println(speciality.getContent());
}
}
catch ( SQLGrammarException e )
{
System.out.println( "ERROR" );
System.out.println( e.getMessage() );
System.out.println( e.getSQL() );
System.out.println( e.getSQLException() );
e.printStackTrace();
}
HibernateUtil.closeSession();
Full stack trace of any exception that occurs:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Hibernate: select vacation0_.vacationId as vacationId, vacation0_.startDate as startDate23_, vacation0_.endDate as endDate23_, vacation0_.year as year23_, vacation0_.type as type23_, vacation0_.kei as kei23_ from babadmin__vacation vacation0_
ERROR
could not execute query
select vacation0_.vacationId as vacationId, vacation0_.startDate as startDate23_, vacation0_.endDate as endDate23_, vacation0_.year as year23_, vacation0_.type as type23_, vacation0_.kei as kei23_ from babadmin__vacation vacation0_
java.sql.SQLException: Base table or view not found message from server: "Table 'babadmin.babadmin__vacation' doesn't exist"
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1502)
at org.hibernate.loader.Loader.list(Loader.java:1482)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:365)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:268)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:782)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at Test.main(Test.java:34)
Caused by: java.sql.SQLException: Base table or view not found message from server: "Table 'babadmin.babadmin__vacation' doesn't exist"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2251)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1586)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:107)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1183)
at org.hibernate.loader.Loader.doQuery(Loader.java:363)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:203)
at org.hibernate.loader.Loader.doList(Loader.java:1499)
... 6 more
Name and version of the database you are using:
MySQL 4.1
The generated SQL (show_sql=true):
select vacation0_.vacationId as vacationId, vacation0_.startDate as startDate23_, vacation0_.endDate as endDate23_, vacation0_.year as year23_, vacation0_.type as type23_, vacation0_.kei as kei23_ from babadmin__vacation vacation0_
Hi,
I am new to Hibernate and I am doing some tests.
I tried to execute the query directly in MySQL and the exception is the same, but if I change the from clause to "from vacation vacation0_" it works.
The problem is the same when I execute this code and when I double-click the Vacation class in the tree of the Hibernate Console (eclipse plugin).
Should I do take care about ISAM, MyISAM or innoDB (I am new to these considerations) ?
I have a subsidiary question concerning the plugin for eclipse. Should I use it to generate my class model ? I have already begin to design my class model in a UML graphical tool. I tried to use the reverse engeneering functionality and the generated classes are really close to my data model but not to my UML class model.
Thank you
Lilian