-->
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: syntax error {"Line 1: Incorrect syntax near 'content0_
PostPosted: Fri May 27, 2005 12:34 pm 
I am getting an inner exception of {"Line 1: Incorrect syntax near 'content0_'." }on the following HQL query:


Code:
"select content.Title, content.PageMetadata.ExpiryDate from Content as content where content.PageMetadata.UserId = " + userId + " content.ContentTypeId = 1 " ;                     


However, this one works fine:

Code:
   "select content.Title, content.PageMetadata.ExpiryDate from Content as content where content.PageMetadata.UserId = " + userId;


So, it fails when the ContentTypeId property shows up.

The two classes are mapped on a one-to-one basis with the PageMetadata object using the Content object's primary key as its own. The database is mapped so that page_metadata has its primary key set as a foreign key to content_id, which is the primary key of the "content" database table.

Without dragging people into the guts of these classes too much, has anyone seen this sort of "content0_" syntax error before? It seems like a strange format, I figured maybe somebody would have a quick fix for this.


Top
  
 
 Post subject: whoops...
PostPosted: Fri May 27, 2005 12:44 pm 
Just as firing up a cigarette in a restaurant guarantees that your food will arrive, posting in a forum instantly makes one see one's error.

The query is missing an "and".

Sorry if you read this and I wasted your time :oops:


Top
  
 
 Post subject:
PostPosted: Fri May 27, 2005 1:14 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
And remember to use parameters instead of manual HQL construction, it will make your queries more clear and eliminate the risk of SQL injection ;-)


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.