-->
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: Prboleme GRAVE: You have an error in your SQL syntax;
PostPosted: Sun Sep 30, 2007 5:02 am 
Newbie

Joined: Sun Sep 30, 2007 4:36 am
Posts: 8
Bonjour,

je commence a travailler avec hibernate, pour ce qui concerne
les insert/update, ca marche, mais des que je fais un

session.find( "from toto");

j'ai le message

GRAVE: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use

j'ai un mysql 5.0.45
la derniere release du connecteur jdbc, 5.3.1
hibernate plugin synchronize 2.3.1
Eclipse 3.3
core hibernate 3.2

Quelqu'un peut me donner une liste de version de jar qui fonctionne

Merci

ATTENTION: SQL Error: 1064, SQLState: 42000
30 sept. 2007 10:38:13 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
GRAVE: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from' at line 1
30 sept. 2007 10:38:13 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
ATTENTION: SQL Error: 1064, SQLState: 42000
30 sept. 2007 10:38:13 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
GRAVE: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from' at line 1
Exception e1:
30 sept.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 30, 2007 7:43 am 
Newbie

Joined: Sun Sep 30, 2007 4:36 am
Posts: 8
j'ai fait le point, j'avais effectivement un mauvais niveau de plug in.

j'ai resolu ce probleme, par contre j'ai un autre probleme.

J'ai un programme insere et qui affiche apres insertion

Mais j'ai une erreur du "objet non mappe", alors que je l'ai fait
il a bien insere mes donnes en base, mais quand je fais le query juste après il se plante.

Mon bout de code
try {

Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();

Client client = new Client();

client. setNom("Alf");
client.setPrenom("alien");
session.save(client);

Facture facture = new Facture();

facture.setPiece("1234");
facture.setMttc( new Float(100) );
facture.setIdcli( client.getId());

facture.setPiece("1456" );
facture.setMttc( new Float(101) );
facture.setIdcli( client.getId());

facture.setPiece("9256" );
facture. setMttc( new Float(102) );
facture.setIdcli( client.getId());
session.save(facture);

tx.commit();

System.out.println("commit ok");

// affiche les insertions

Iterator it;
System.out.println("=====================");
Query query = session.createQuery("from client");

it = query.iterate();

while(it.hasNext())
{
client = (Client)it.next();
System.out.println(client.getNom());
System.out.println("=====================");

}

HibernateUtil.closeSession();

System.out.println("ok");

}
catch ( Exception e1 ) {
e1.printStackTrace();
}
}


Resultat

commit ok
=====================
org.hibernate.hql.ast.QuerySyntaxException: client is not mapped [from client]
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:255)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3056)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
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:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
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:72)
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:1623)
at TestHib.main(TestHib.java:55)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 30, 2007 8:16 am 
Newbie

Joined: Sun Sep 30, 2007 4:36 am
Posts: 8
ok j'ai trouvé, je dois utilise nom logique du mapping de la table et non son nom physique, autant pour moi

mon de mappming c'est Client, ma table CLIENT, les minuscules/majuscules ont leur importance.


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.