aspose file tools*
The moose likes Object Relational Mapping and the fly likes How to get the starting position of a string using hibernate query. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How to get the starting position of a string using hibernate query." Watch "How to get the starting position of a string using hibernate query." New topic
Author

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

Hariharan.S
Greenhorn

Joined: May 25, 2005
Posts: 7
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

Joined: Apr 14, 2004
Posts: 10336

"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!


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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

Joined: Aug 24, 2005
Posts: 518
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.
 
Consider Paul's rocket mass heater.
 
subject: How to get the starting position of a string using hibernate query.