Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get the starting position of a string using hibernate query.

 
Hariharan.S
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

How to get the starting position of a string using hibernate query. For example we will use �patindex� to get the position of the string in sqlserver. It will return an integer value based on the starting position of the given string .

Thanks.
Hari.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Hariharan"

Welcome to JavaRanch!

As other have already pointed out, your display name does not comply with our Naming Policy. In particular it must include both first and last name. Please change it here. Thanks!
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is nothing in HQL that matches this. You could use T-SQL directly, since Hibernate supports the use of platform-specific SQL (see the createSQLQuery method) however this would break portability. Doing the work in your application via Java might be the best way though.
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another alternative is to move the call to patindex() to a stored procedure and call the procedure from Hibernate. The procedure could return the position as a single scalar.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic