-->
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.  [ 3 posts ] 
Author Message
 Post subject: could not execute query
PostPosted: Tue Sep 12, 2006 7:21 am 
Newbie

Joined: Tue Sep 12, 2006 7:13 am
Posts: 2
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.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 12, 2006 12:17 pm 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
Hi,
maybe the table is in another schema?

_________________
Please don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 12, 2006 2:24 pm 
Newbie

Joined: Mon Sep 11, 2006 4:50 pm
Posts: 10
Take a look at this:
Quote:
'TB_VILLES' : nom d'objet incorrect.

Maybe the table name isn't exactly that, or maybe is in another schema as Mike said.
Good Luck!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.