Hi,
I'm trying to use hibernate and myeclipse.
I have the table TB_VILLES (code, nom...), TB_VILLES is mapped to TbVilles
I would like to test my application, i use this code
Quote:
public class Test {
public static void main(String[] arg) {
System.out.println("OK");
Session session = HibernateSessionFactory.currentSession();
Transaction tx = null;
tx = session.beginTransaction();
Query q = session.createQuery("from TbVilles v where v.code='ABC'");
List list = q.list();
Iterator it = list.iterator();
while(it.hasNext()) {
TbVilles v = (TbVilles)it.next();
System.out.println(v.getnomVille());
}
I got this error message:
Quote:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1596)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at service.Test.main(Test.java:23)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: 'TB_VILLES' : nom d'objet incorrect.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.IOBuffer.processPackets(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.sendExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteQuery(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(Unknown Source)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1272)
at org.hibernate.loader.Loader.doQuery(Loader.java:391)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
... 6 more
please help me.