Native « Query « JPA Q&A





1. Hibernate is much faster when executing a native query    stackoverflow.com

The following query is supposed to return about 800 objects. The problem is that hibernate actually executes 800 queries to get them all. It appears to execute one query to get ...

2. JPA native query and cache    stackoverflow.com

Does native query in JPA (createNativeQuery) supports caching?
I am filling my own data transfer object because the sql query joins several tables and takes only several columns form them. Regards

3. JPA Native Query using the SQL 'IN' clause    stackoverflow.com

I'm trying to create a query such as: select * from table1 t1 where t1.id In (select t2.id from table2 t2 where ...) Can I use a native query to do that? What is ...

4. Avoid N+1 select with native sqlQuery?    stackoverflow.com

Here's what I have :

Entity A -> oneToMany -> Entity B -> manyToOne -> Entity C
And because I have to do an inner join without foreign keys between A and another ...

5. JPA Native Query    stackoverflow.com

I am trying to execute a native query and pass run-time parameters and get the result as a List. When I try to process the Object [], one of the columns ...

6. JPA Native Query (SQL View)    stackoverflow.com

I have two Entities Customer and Account.

@Entity
@Table(name="customer")
public class Customer
{
    private Long id;
    private String name;
    private Long accountId;
    private ...

7. Can I drop table using hibernate native SQL query    stackoverflow.com

I am trying to drop the temp table using hibernate native SQL (createSQLQuery) statement. Here is code:

session.createSQLQuery("DROP TABLE tmp_dummy_table").executeUpdate();
However It throws me below exception:
SQL Error: 1003, SQLState: 24000
ORA-01003: no statement parsed

Exception ...

8. Hibernate is great, but Native query support is limited    coderanch.com

Hi all, My company is using Hibernate as the ORM tool for our latest project. Unfortunately, we are constrained by our obligatory use of a badly designed legacy database. As such, we have several unwieldy queries (some over 4 pages long with 10+ joins). I spent a day last week attempting to convert our existing JDBC code to a native Hibernate ...

9. Hibernate: native query to wrap the collection    coderanch.com

Sure, if you're asking if you can do a regular select, it's no problem. Here's a sample snippet: final static String SELECT = "SELECT * FROM USER"; private static void hibernateNativeQueryFindAll(SessionFactory factory) { Session session = factory.getCurrentSession(); session.beginTransaction(); SQLQuery sqlQuery = session.createSQLQuery("SELECT * FROM USER"); List results = sqlQuery.list(); for (int i = 0; i < results.size(); i++) { Object[] o ...





10. RFI | Native Query | Hibernate    coderanch.com

Hi, I am using hibernate for interacting with database. I have three tables Tbl_Product (Table - 1) ----------------------- Product_Id (PK) Product_Title Product_Number (Unique) Tbl_Product_Person_Map(Table - 2) --------------------------------- Map_Id (PK) Product_Id (FK) Person_Id (FK) Tbl_Person (Table - 3) ------------------------ Person_Id (PK) Person_Name My Entities are - 1) Product.java Integer productID; String productNumber; //Being alphanumeric String productTitle; Collection productPersonMap; //Tbl_Product has one to ...

11. Problem with a native query in JPA    coderanch.com

Hi, maybe someone could point me in the right direction.. I have a native query: "SELECT COUNT(1) FROM VERPFLICHTUNG v WHERE v.ID_FORDERUNG = ? AND v.LFDNRVERPFLICHTUNG = ?" I expect it to return a single value, so I am trying to call like that: em.createNativeQuery( queryClaimSerialNumber ).setParameter( 1, claimNumber ).setParameter( 2, serialNumber ).getSingleResult(); getSingleResult is supposed to return an Object, but ...

12. JPA Native Query    coderanch.com

13. JPA named native query    coderanch.com

When a database user connect to the database they are assigned to a schema. Which schema they are assign to is defined on the database. If your database user is not connecting to DO3 schema, then it will need to include the schema in referencing the table. How are you setting your schema for generating SQL in JPA? Are you setting ...

14. Native Queries    forum.hibernate.org

Hello, In some circumstances we need to execute database depended native queries. As some customers have this database and others that one, we need to support a query in more than one dialect. Therefore we keep the statements in files named according to the database name, e.g., "sqlserver.sql" AFAIK the native query annotations do not support this, do they? How can ...

15. Named Native Query getting modified in Hibernate3    forum.hibernate.org

Newbie Joined: Thu Dec 10, 2009 7:43 am Posts: 2 I am using a workload with the annotated NamedNativeQuery used in one of the source files as: Code: @NamedNativeQueries({ @NamedNativeQuery(name="quoteejb.quoteForUpdate", query="select * from quoteejb q where q.symbol=? for update",resultClass=org.apache.geronimo.samples.daytrader.QuoteDataBean.class) }) When I run this app using Hibernate 3.2.6 jars, it goes through fine with the query during ...

16. Adding native sql where clause to the hql    forum.hibernate.org





17. Native queries    forum.hibernate.org

Is there anything special about native queries that I should be aware of when using them? Is there any reason to prefer them over HQL queries or to avoid them? In general, what's the difference between doing something via an HQL and an SQL query? [OFF TOPIC] I was forced to register a new account due to some problem with the ...

18. SQL Native Query Union    forum.hibernate.org

Author Message misge Post subject: SQL Native Query Union Posted: Wed Apr 14, 2010 6:17 am Newbie Joined: Wed Apr 14, 2010 6:05 am Posts: 1 Hi all, I'm trying to use the following SQL Query: @NamedNativeQuery(name="archive&file", query=" SELECT id, "+ " sender_id, "+ " date_created "+ " FROM DOCUMENT_ARCHIVE da "+ " where da.SOURCE_FILE_NAME = 'shpaig0140_shpsts_shpaig_C2KRMP1.txt' "+ " ...

19. problem with native query under jpa with same column names    forum.hibernate.org

Hi, I'm using hibernate 3.5.0-CR2 with MySQL server 5.1.44 (through mysql-connector-java-5.1.9) on Windows. I'm using JPA 2.0 and issuing a native query. The query runs fine when run directly agains the server using MySQL Browser. When I run it through JPA/Hibernate, the number of items returned is correct but the values returned for each item is not correct. I believe this ...

21. native query in hibernate3    forum.hibernate.org

Hello, I am writing a native query which has some comparisions with dates, and it does not work through hibernate but works on the PL/SQL developer. My code is as follows : SQLQuery q = session.createQuery(" select {x.*}, {y.*}, {z.*} from X x, Y y, Z z where to_char({x}.date, 'mm/dd/yyyy hh24mi') >= to_char(:date, 'mm/dd/yyyy hh24mi') "); q.addEntity("x", X.class); q.addEntity("y", Y.class); q.addEntity("z", ...

22. Newbie - native SQL 'AS' clause in HQL    forum.hibernate.org

23. help in creating native sql query    forum.hibernate.org

I am still getting the error .. Hibernate: select max(s.stat_stamp),a.syscompid from stats.stats s,stats.syscomps a where s.syscompid=a.syscompid and a.syscompid is not null group by a.syscompid Exception in thread "Main Thread" org.hibernate.exception.GenericJDBCException: could not execute query at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.loader.Loader.doList(Loader.java:2223) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104) at org.hibernate.loader.Loader.list(Loader.java:2099) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695) at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152) at com.nomura.dbe.atrisk.stats.StatsDaoHelper.GetMaxTimestamp(StatsDaoHelper.java:199) at com.nomura.dbe.atrisk.stats.StatsDao.GetMaxTimestamps(StatsDao.java:366) at com.nomura.dbe.atrisk.stats.StatsDao$$FastClassByCGLIB$$1b4b95e.invoke(ILjava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(:???) at ...

24. JPA Hibernate native Query to "unmapped" table    forum.hibernate.org

/** * Interface for all result extractors. */ interface ResultExtractor { public T getResult(List resultSet); } /** * Extractor for single integer result. You have to set number of needed * column in the result set row. */ class IntegerExtractor implements ResultExtractor { private final Integer numberOfColumn; public IntegerExtractor(int numberOfColumn) { this.numberOfColumn = numberOfColumn; } public Integer getResult(List resultSet) { if ...

25. native query: setTransform    forum.hibernate.org

I am using the following native query to get info back from an informix DB. I am trying to use the setResultTransform method to map the results to a dto class. I got it to work, but had the following problem: when I renamed the columns to "myFlag1,myFlag2", it converted them to lowercase. I had to define new setter methods in ...

26. Identify if HQL or native SQL query    forum.hibernate.org

My requirements is - if i have an , i use filter.. and since doesn't support filter, I have to append an AND clause to my SQL query.. so based on whether it is a HQL or SQL query, i have to make changes but am unable identify the type.. Any suggestions?

27. Native Query GOTCHA    forum.hibernate.org

Newbie Joined: Sat Aug 30, 2003 5:46 am Posts: 5 I thought I would post here a problem I've just spent a while figuring out. The setup is Hibernate 3.6, JPA, Postgresql 8.4 I have a native query which looks like Code: SELECT p.project_id, p.project_ref, p.project_name, p.description, (SELECT u.full_name FROM users ...

28. Hibernate can not query the right resule while native sql c    forum.hibernate.org

This is the test code,first use hibernate ,then use the native sql: Code: @Test public void testSQLAndHibernate() throws ParseException { start = sdf.parse("2011-02-22 10:00:00"); end = sdf.parse("2011-02-22 16:00:00"); // use hibernate ...

29. How to write Externalized native sql query in hibernate    forum.hibernate.org

HI All, I have table with 30 columns and I mapped those to one entity value object. Now I need to get only three columns from that table. For that I had written One externalized native sql query in hbm file. I need to get these result in to my customized another value object, that value object having those properties only. ...

30. Partially native SQL query    forum.hibernate.org

31. Hibernate 4 native query    forum.hibernate.org

32. Native Queries    forum.hibernate.org

Hi, Im trying to use Native Queries with the following code Code: public static void findTest(Session session) throws HibernateException { //"SELECT {fecha}.descripcion AS {fecha}.descripcion FROM segu_fecha_inhabil {fecha} WHERE {fecha}.fecha NOT IN (SELECT z.fecha FROM segu_sistema_fecha_inhabil z WHERE z.sistema='TELLER')", List result = session.createSQLQuery( ...

33. More explicit problem with native queries    forum.hibernate.org

When I want to do a Native Query I have the next code: Code: List result = session.createSQLQuery( "SELECT {f}.descripcion AS {f.descripcion} FROM segu_fecha_inhabil {f} WHERE {f}.fecha NOT IN (SELECT z.fecha FROM segu_sistema_fecha_inhabil z WHERE z.sistema='TELLER')", "f", SeguFechasInhabiles.class).list(); In this case I receive the next error ...

34. Native SQL query and collection many-to-many    forum.hibernate.org

Beginner Joined: Mon Mar 29, 2004 12:41 pm Posts: 26 Hi all ! I have 3 tables : - VERSIONDECOMPOSANT, - ENVIRONNEMENT, - AS_VERCOMP_ENV : The association table between the two above. I have the following exception when I try to get my data from the DB : Code: Alias [as_vercomp_env] does not correspond to any of the supplied return aliases ...

35. Hibernate Native query    forum.hibernate.org

36. Create table in sql server using native query    forum.hibernate.org

37. HQL or native SQL for a SQL query with multiple joins    forum.hibernate.org

Hibernate version:2.1.6 Hi, Please help me to get the results of the following SQL query using HQL or native SQL support in hibernate. Code: select g.categoryid, g.categoryname, sum(b.amount) totalbill, sum(case when c.gender='F' then b.amount else 0 end) totalfemalebill ...

38. Problem with native SQL Queries on iSeries    forum.hibernate.org

I have an app using Hibernate attaching to a DB2/400 (V5R2) database on an iSeries. All is working fine with my regular HQL stuff. Recently I had a need to do a native SQL query. I set up my query and it ran fine, with one issue. The native query return the data in HEX format, not readable at all. Any ...

39. scroll with native query    forum.hibernate.org

40. Query excepton while using native sql query-please help!    forum.hibernate.org

Newbie Joined: Fri Feb 04, 2005 4:11 pm Posts: 10 Read the rules before posting! http://www.hibernate.org/ForumMailingli ... AskForHelp I must be missing something really basic here, but I have not been able to resolve this error for a while now. I am trying to use a native SQL query in the mapping document, and I get a ORA-00933: SQL command not ...

41. Native SQL Query    forum.hibernate.org

Hi all, I'm trying to construct a Native SQL Query from Hibernate where the REAL sql is: select pch.* from product_category pc inner join product_category_hierarchy pch on pch.child_id = pc.id where pc.aid = 4 and pch.parent_id=0; My best attempt at this is: Session ssn = TestSessionFactory.currentSession(); Query sqlQuery = ssn.createSQLQuery( "select {pch.*} from product_category {pc} " + "inner join product_category_hierarchy {pch} ...

42. help reading objects from a native query    forum.hibernate.org

hi, i'm trying to use a native query and retrieve the results. the following code executes a simple query. the first println() reports a list size of 23, so i know objects are being returned. however, the row array has a size of zero! what's going on here? Code: String sql = "select category, category_key from categories ...

43. Native SQL update - query not executing??    forum.hibernate.org

Session session = sessionFactory.openSession(); java.util.Date currentTime = new java.util.Date(); Connection c = session.connection(); PreparedStatement ps = c.prepareStatement("update USER set LAST_LOGIN = ? where USER_ID = ?"); ps.setDate(1, new java.sql.Date(currentTime.getTime())); ps.setInt(iUserId); log.debug("Executing statement..."); int iRowsUpdated = ps.executeUpdate(); log.debug(iRowsUpdated + " records updated in table USER"); ...

44. native sql query    forum.hibernate.org

I have a native sql query to a oracle database, but i don't get any result. Here is the code: String query="SELECT {NSIL_CORE.*} FROM {NSIL_CORE} WHERE SDO_RELATE(IGEOLO_SDO, mdsys.sdo_geometry(2003,8307, NULL, mdsys.sdo_elem_info_array(1,1003,1), mdsys.sdo_ordinate_array(0.0,100.0 , 0.0,0.0 , 100.0,0.0 , 100.0,100.0, 0.0,100.0)), 'mask=INSIDE+COVEREDBY querytype=WINDOW') = 'TRUE'"; List result=session.createSQLQuery(query).addEntity("NSIL_CORE", Nsil_core.class).list(); Are there any brackets missing? Thanks for help!

45. native queries    forum.hibernate.org

Hi to all! I am using a native query in MySQL to find a match in a fulltext field (I have to use the MATCH ...AGAINST function in MySQL). I can retrieve the result of my query: private static String SQLQuery = "SELECT {users.*} FROM users WHERE MATCH(firstName, lastName, email, address, city, province, state, nationality, phone, mobile, profession, attributes) AGAINST(:search)"; here ...

46. Native SQL queries    forum.hibernate.org

Hi, I am new to hibernate and have a question . I have a table which is created in mysql called RULES and has the following colums int id, field varchar(20), operator varchar(10), value varchar(20) This was an existing table and I have to use it as read only. Now I want to use hibernate to retrieve results from this table. ...

47. Native SQL Query in many-to-many    forum.hibernate.org

I have a class Person, which is associated with Person many-to-many associaton, . . . I need to write a query which will check if given two person are friends. In native SQL this query would be something ...

48. problem with native sql query    forum.hibernate.org

String sql = "select cat.originalId as {cat.id}, " + "cat.mateid as {cat.mate}, cat.sex as {cat.sex}, " + "cat.weight*10 as {cat.weight}, cat.name as {cat.name} " + "from cat_log cat where {cat.mate} = :catId" List loggedCats = sess.createSQLQuery(sql) .addEntity("cat", Cat.class) .setLong("catId", catId) ...

49. Native SQL Query Problem    forum.hibernate.org

I'm trying to use a native SQL query using session.createSQLQuery. It works fine for me when I try and return a list of objects using String sql = "SELECT {org.*} FROM organisational_unit org START WITH organisational_unit_id="+orgUnitId+" CONNECT BY PRIOR organisational_unit_id=orgunit_parent_id"; but if I try and return a column I get an SQLException: Invalid column name. I know that the query works ...

50. Native SQL Query    forum.hibernate.org

Thanks for the reply. I think my query was a bit misleading. I know native sql joins very well.. but dont how to implement those joins in hibernate. I've two table EMP ---- EMP_ID EMP_NAME DEPT -------- DEPT_ID EMP_ID and my sql query in oracle sql is Select Emp.*, DEPT.* from EMP, DEPT where EMP.EMP_ID=DEPT.EMP_ID. How to implement this in hibernate? ...

51. Native SQL and Query cache    forum.hibernate.org

52. Cannot get native SQL query to excute    forum.hibernate.org

I am trying to get this query to run: Code: SELECT {a}.userName as {a.username}, count(*), concat(format(avg( time_to_sec({r}.reviewEnd) - time_to_sec({r}.reviewStart) ) / 60,2), ' min') FROM reviewPhase {r} INNER JOIN account {a} on {a}.id = {r}.accountId WHERE {r}.queueId = :queueId AND {r}.reviewStart BETWEEN '2005-8-1 00:00:00' AND '2005-8-1 23:59:59' ...

54. Native SQL Query -->get Column_name from all_tab_columns    forum.hibernate.org

Thx for your quick reply! The problem is, that if I do the following sqlquery: Code: String name =(String) session.createSQLQuery("select column_name from all_tab_columns where table_name='ET_EDISECTOR'").addScalar("all_tab_columns", Hibernate.INTEGER).uniqueResult(); I get the following stack: Code: Caused by: org.hibernate.exception.GenericJDBCException: could not execute query at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.loader.Loader.doList(Loader.java:2150) ...

55. Native SQL vacuum query?    forum.hibernate.org

56. Native query cannot be executed    forum.hibernate.org

57. Bizarre Problem with hibernate native sql queries    forum.hibernate.org

Hibernate version: 3.0 Hi There, I am generating an SQL query in two ways 1. Using a Criteria - works fine. 2. Using a native SQL query using createSQLQuery - does not work. Using this approach I get the error: [OraDriver] Column not found . This is the code that executes the statement and then gets the results: Code: ...

58. Executing native sql queries    forum.hibernate.org

Hello, I am trying to figure out how to execute a (native) SQL query and put the result in a java variable: select avg(datediff(dc.diffusionEPReelle, dc.accuseReceptionReelle))) from E37T_T_DateCle ; This query returns the mean number of days between two date columns, and i need to gather this number of days. (a) When executing this code : Integer o = (Integer) (getSession().createSQLQuery( "select ...

59. Is it recommended to use Hibernate3 for Native SQL Queries    forum.hibernate.org

Hi Fellas Their is a huge user community like us who would like to leverage the flexibility of SQL & persistence management of Hibernate . Not sure whether any performance is involved here. Till now I didn't have a good feeling on using Hibernate3 for native sql queries thinking JdbcTemplate from Spring will be ideal for native sql queries. Hope Gavin ...

60. Problems with Native SQL/HQL query using Many-To-Many Relshp    forum.hibernate.org

I am stuck with the issue of getting the queries worked. I am using Many-To-Many Unidirectional relationship between User and Role i.e. i want to list the Roles of a User. I am getting "Invalid Colum" error for Native SQL query Here is my Native SQL query [color=blue]String sql = "select c.last_name as {c.lastName}, c.first_name as {c.firstName} from ced c where ...

61. problem with native sql query (unmapped) links Char(5) with    forum.hibernate.org

Dialect dialect = ((SessionFactoryImpl)this.session.getSessionFactory()).getDialect(); if (dialect instanceof Oracle9Dialect) { //there is a native sql problem where "char" database types get truncated since //read as char, so we will read them as String ...

62. native sql query in hibernate 3.0    forum.hibernate.org

Hi, I'm using hibernate 3.0 in a project and need to call some native sql query.. I use createSQLQuery(queryString) and in hibenrate version 3.0 I'm forced to use addScalar(String, Type) with SQLQuery.. But i query each time a different table and some tables have a string id and other have a long id. Since I don't know the id's type, I ...

63. SAPDB Char problem when using Native Query    forum.hibernate.org

Hello, I am currently working on a web projekt with the purpose of displaying data from a legacy database within a web application. The Database I am using is SAPDB version 7.5.0 . As I do only have to create read-only access to the legacy DB and show the result as simple HTML-Tables I didn' t write hibernate mapping files, but ...

64. Native Query    forum.hibernate.org

public class RemoteDatabaseDaoImpl extends HibernateDaoSupport implements RemoteDatabaseDao { private static final String LOAD_CLUBS = "select d.owner, d.height,d.club, c.cnumber, d.dnumber, c.cname, d.cname from clubs c, dogs d where c.cnumber = d.club and c.payment='processed' and d.payment='processed' and d.status='active'"; private static final Log logger = LogFactory.getLog(RemoteDatabaseDaoImpl.class); ...

65. Native Query    forum.hibernate.org

public class RemoteDatabaseDaoImpl extends HibernateDaoSupport implements RemoteDatabaseDao { private static final String LOAD_CLUBS = "select d.owner, d.height,d.club, c.cnumber, d.dnumber, c.cname, d.cname from clubs c, dogs d where c.cnumber = d.club and c.payment='processed' and d.payment='processed' and d.status='active'"; private static final Log logger = LogFactory.getLog(RemoteDatabaseDaoImpl.class); ...

66. need help about native sql query    forum.hibernate.org

Newbie Joined: Tue Mar 20, 2007 1:45 am Posts: 2 Hi, i am new to hibernate so i am not sure the way i trying to do is correct or not, but i had create a function to handle all native select ... public List getBySQLQuery(String query){ return getSession().createSQLQuery(query).list(); } here my probelm is...when i try to create the sql and ...

67. Problem with hibernate (3.0.2) Native SQL query feature    forum.hibernate.org

[b]Hibernate version:3.0.2 [b]Name and version of the database you are using: Tested with MSSQL, ORACLE Hi all, Recently in our project we have decided to use Hibernate Native SQL query capabilities. We are facing a problem with mapping the query results with the java class properties. Basically hibernate is not allowing us to run the named queries if the sql query ...

68. Hibernate - native SQL query - problems    forum.hibernate.org

I'm doing a native SQL query against Oracle and the query object says there are no return results but when I do query().list(), I get info that there is an array of chars with one row. Can anyone tell me why I am getting a single char back? I have a copy of my query below. I am doing the following: ...

69. native sql query    forum.hibernate.org

70. Named Native Query    forum.hibernate.org

71. Translate Native SQL to Criteria Query    forum.hibernate.org

Hibernate version: 3.2.4 Mapping documents: MEMBERSHIP Code between sessionFactory.openSession() and session.close(): 1 session.beginTransaction(); 2 int b=1; 3 String qry= 4 "select m2.* from "+ 5 "(select * from "+ 6 ...

72. Disabling invalidation of 2nd level cache on native query    forum.hibernate.org

Hi, It seems like hibernate deliberately evicts all my second-level cache regions whenever the executeUpdate() method for a native query is executed. Is there any way to work around or stop this behavior? I have a stored procedure call that I have to call periodically, and every time it runs, all my 2nd level cache entries are evicted. Any help is ...

73. Native SQL query - Can't be executed by hibernate    forum.hibernate.org

Newbie Joined: Tue Jun 08, 2004 8:50 am Posts: 3 Hibernate version: 3.2 Mapping documents: Not Relevant Code between sessionFactory.openSession() and session.close(): Code: String mainQuery = "select count(*) as ihaleAdet, sum(iar.sovtaj) as toplamSovtaj, sum(iar.rayic) as toplamRayic, iar.other as name, sum(iar.hasar) as toplamHasar " + ...

74. problem with native sql query    forum.hibernate.org

75. problem with native sql query    forum.hibernate.org

76. Native SQL Query with ResultTransform and scrolling.    forum.hibernate.org

Newbie Joined: Mon Oct 20, 2008 6:40 pm Posts: 1 Hello people, BACKGROUND I wrote an a Native SQL Query. This happens to be a SELECT query. Each of the returned columns has an alias using the AS keyword. For example: SELECT f.id AS id, f.name AS name FROM foobar. I also using scrolling, as supported by hibernate. I am using ...

77. Using Native Sql and where clause    forum.hibernate.org

Hi, I have to use native sql in hibernate. when is issue the below query it is fetching records String query="select order_number from oha" Query queryHql=hibernateSession.createSQLQuery(query.toString()); List list=queryHql.list(); it is fetching all records. But when i add where condition String query="select order_number from oha where xxx='CC'" there comes no results eventhough there are records matching with the criteria. Can anybody please ...

78. SQL injections for Hibernae Native Query Support    forum.hibernate.org

Hello, Hibernate is pretty safe of sql injection as it uses preparedStament. I have been using Hibernate Native Query support heavily in my application and as far as i have learnt native query is not sql injection safe. Is there any mechanism that can be set at hibernate layer to make it safe from sql injection? rather then manually filtering all ...

79. Pure native queries not supported!    forum.hibernate.org

80. Need help on using Native SQL Query    forum.hibernate.org

Hi, i need help in using native sql query. i have a query like this : Code: public class ArrivalReportBean { private SessionFactory sf; private final String query = "SELECT h.dateTr,111, h.noTr, dt.pKey, SUM(dt.quantity) * -1, dt.unitPrice, " + "SUM(dt.quantity) * ...

81. Pure native scalar queries are not yet supported    forum.hibernate.org

82. Native query & second-level cache problem    forum.hibernate.org

Here is the scenario, We have an entity, which is the result of a native query, joining 3 tables together. We have query cache as well as second level cache enabled. We are testing the timeToLiveInSeconds attribute. Every 15 minutes, we want the cache to refresh. But for testing purposes we've set this attribute to 5s and running multiple sequential queries ...

83. Multiple Table Selects with Native SQL    forum.hibernate.org

I have 3 tables that can be joined by a simple orderkey. However, I only need to have 2 fields from each table brought into my domain object. Do I have to model a domain object for each database table in order to retrieve the data with hibernate or can I use native SQL to just select the fields I need ...

84. Native SQL Query, not honoring Column Order    forum.hibernate.org

85. Native SQL Queries and how to get the column names??    forum.hibernate.org

hi, I would like to get the Column Names out of a native SQL Query. The query looks like that for example: String sqlCMD = "SELECT SQL_CALC_FOUND_ROWS c.diagramobject_id, c.objecttypename, c.name " + "FROM diagramobject c " + "LEFT OUTER JOIN diagramobject_property d ON (d.diagramobject_id = c.diagramobject_id) " + "WHERE c.organisation_id="+organization_id+" " + "AND lower(c.name) LIKE lower('"+search+"') " + "AND c.deleted NOT ...