native-sql

org.hibernate.QueryException: Space is not allowed after parameter prefix ':'

北慕城南 提交于 2020-01-16 14:11:15
问题 I'm trying to execute query , but got Resolved exception caused by handler execution: org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.QueryException: Space is not allowed after parameter prefix ':' . I done as advised here How can I use MySQL assign operator(:=) in hibernate native query? and here : Hibernate exception on encountering mysql := operator But same. hibernate version 5.2.17.Final ClientRepository.java @Repository public interface ClientRepository extends

Write native SQL in Core Data

时光怂恿深爱的人放手 提交于 2019-12-20 03:11:14
问题 I need to write a native SQL Query while I'm using Core Data in my project. I really need to do that, since I'm using NSPredicate right now and it's not efficient enough (in just one single case). I just need to write a couple of subqueries and joins to fetch a big number of rows and sort them by a special field. In particular, I need to sort it by the sum of values of their child-entites. Right now I'm fetching everything using NSPredicate and then I'm sorting my result (array) manually, but

Hibernate: Can I return a non-mapped list of objects that contains a List?

牧云@^-^@ 提交于 2019-12-13 18:12:34
问题 I currently use .addScalar and ResultTransformer to return a non-mapped list of objects that do not have any List variables. I'd like to modify my object to contain a List. Following an initial example provide in Hibernate documentation, I successfully accomplished something similar to: sess.createSQLQuery("SELECT ID as id, NM_CDE as nameCode, NM_VALUE as nameValue FROM EMP") .addScalar("id", Hibernate.LONG) .addScalar("nameCode", Hibernate.STRING) .addScalar("nameValue", Hibernate.STRING)

How To Utilize Doctrine2 Type Conversion on Native Query COLUMNS

独自空忆成欢 提交于 2019-12-12 12:06:48
问题 Could not find anything on this-- seems like it should be straight forward though. So the example the Doctrine2 docs give for type conversion on bound parameters looks like this: $date = new \DateTime("2011-03-05 14:00:21"); $stmt = $conn->prepare("SELECT * FROM articles WHERE publish_date > ?"); $stmt->bindValue(1, $date, "datetime"); $stmt->execute(); What I want to do is specify the type conversion for one of the columns, but there is nothing in the documents or on StackOverflow that I

Retrieving a value from Stored Procedure using Native SQL Hibernate

僤鯓⒐⒋嵵緔 提交于 2019-12-11 04:59:01
问题 Below is the stored procedure: create or replace procedure proc_emp_name(v_emp out emp.emp_name%TYPE, v_empid in emp.emp_id%TYPE) is begin select emp_name into v_emp from emp where emp_id = v_empid; dbms_output.put_line('Emp Name: ' || v_emp); dbms_output.put_line('Procedure created successfully!!!'); end; I want to invoke this using Native SQL, followed this link but not sure how to retrieve the OUT parameter from the Procedure. http://www.mkyong.com/hibernate/how-to-call-store-procedure-in

org.hibernate.MappingException: No Dialect mapping for JDBC type: 1111 for jsonobject with custom JsonPostgreSQLDialect

耗尽温柔 提交于 2019-12-11 03:35:59
问题 1) I added custom dialect by extending PostgreSQL9Dialect which does this.registerColumnType(Types.JAVA_OBJECT, "jsonb"); 2) public class JSONObjectUserType implements UserType { } 3) property name="xxxx" type="org.JSONObjectUserType" length="1000" 4) I run hibernate native SQL query. SQLQuery query1 = (SQLQuery) session.createSQLQuery(str.toString()); It is giving No Dialect mapping for JDBC type: 1111. str = "Select state from X" Postgresql - column state is of type jsonb. 来源: https:/

Spring data - insert data depending on previous insert

你。 提交于 2019-12-10 16:28:33
问题 I need to save data into 2 tables (an entity and an association table). I simply save my entity with the save() method from my entity repository. Then, for performances, I need to insert rows into an association table in native sql . The rows have a reference on the entity I saved before. The issue comes here : I get an integrity constraint exception concerning a Foreign Key. The entity saved first isn't known in this second query. Here is my code : The repo : public interface

Hibernate Native SQL Query retrieving multiple entities in join

痞子三分冷 提交于 2019-12-07 13:31:09
问题 Referencing with this answer to this correlated thread, the trick posted by ehrhardt works fine. But, what I have to do if I have to join with multiple entities? for example: List<Person> peopleWithBooks = session.createSQLQuery( "select {p.*}, {b.*}, {m.*} from person p, book b, magazine m where <complicated join>") .addEntity("p", Person.class) .addJoin("b", "p.books") .addJoin("m", "p.magazines") .addEntity("p", Person.class) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) .list();

Hibernate Native SQL Query retrieving multiple entities in join

我的未来我决定 提交于 2019-12-06 01:39:02
Referencing with this answer to this correlated thread, the trick posted by ehrhardt works fine. But, what I have to do if I have to join with multiple entities? for example: List<Person> peopleWithBooks = session.createSQLQuery( "select {p.*}, {b.*}, {m.*} from person p, book b, magazine m where <complicated join>") .addEntity("p", Person.class) .addJoin("b", "p.books") .addJoin("m", "p.magazines") .addEntity("p", Person.class) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) .list(); Hibernate aggregates right the first join, but not the second (magazine entities are not grouped). There

Difference between query, native query, named query and typed query [closed]

可紊 提交于 2019-12-04 07:32:52
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . What are the differences between a query, a native query, a named query and a typed query? Does the 'alone-standing' query even exist, or is it just an abbreviation? In my mind, a native Query is a query written in simple sql, whereas a named query relates to entities (hibernate