Questions tagged [hibernate-native-query]
107 questions
1
vote
0 answers
SELECT query in Dropwizard database healthcheck
Hello I am using dropwizard and hibernate in my application and have written the following heakthcheck. This gives me a
org.hibernate.engine.jdbc.spi.SqlExceptionHelper: ResultSet is from UPDATE. No Data. error
I tried changing the…

user_mda
- 18,148
- 27
- 82
- 145
1
vote
1 answer
Get inserted Id from NativeQuery Hibernate 5.2+
I am using the following code to run native sql queries on hibernate (SQLQuery) has been deprecated.
private static int executeUpdate(String sql) {
int result = 0;
Session session = HibernateSessionFactory.getSession();
…

absin
- 1,116
- 10
- 21
1
vote
1 answer
Hibernate native sql query exception - rs cursor forward only
I am dealing with a legacy code that is 'not changeable' (no way to move to criteria api) and I have a little trouble with proper parameters binding. The query looks like this (MS SQL):
SELECT BRAND AS b FROM CAR WHERE (NAME LIKE :phrase OR MODEL…

user3529850
- 1,632
- 5
- 32
- 51
1
vote
2 answers
Hibernate Neo4j retrieve result in a key-value form
I would like to retrieve entity properties in a format like this: property_name: value.
I am trying to get the result this way:
public void retrievePerson(){
EntityManagerFactory emf = Persistence.createEntityManagerFactory("persistence");
…

Porjaz
- 771
- 1
- 8
- 28
1
vote
1 answer
Bind native query error. EclipseLink(JPA 2.1)
Error binding variables to native query. EclipseLink(JPA 2.1)
String sql = "ALTER ROLE ?1 WITH ENCRYPTED PASSWORD 'xxx'"; //(not working)
//String sql = "ALTER ROLE ? WITH ENCRYPTED PASSWORD 'xxx'"; (not working)
Query query =…

Ramon González
- 27
- 1
- 5
1
vote
0 answers
Java.util.UUID is saving as BLOB in Mysql DB
public class Test{
@Id
@JsonIgnore
@GeneratedValue(generator = "uuid2")
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name="TEST_ID",columnDefinition = "BINARY(16)")
@Type(type="uuid-binary")
…

Veds
- 11
- 1
- 6
1
vote
1 answer
Executing an SQL command with EntityManager
Is it possible to run an SQL script that doesn't return a resultSet or is not an INSERT or UPDATE type of script?
I'm trying the following:
Query q = entityManager.createNativeQuery("DECLARE @max int;\n" +
"SELECT @max =…

Steve Waters
- 3,348
- 9
- 54
- 94
1
vote
1 answer
Query is always returning 0 rows
I am new to Hibernate and trying to implement simple native query but I am always getting 0 rows. If the same query I am directly running in db then I can see the records.
Query query = (Query) entityManager.createNativeQuery("SELECT * FROM…

user3541321
- 165
- 5
- 19
1
vote
2 answers
How to return List
I want to return a List of maps from my createNativeQuery().getResultList(), where each map is a pair key - value representing column name - value. I already tried to use direct in the method like this:
public List

Kim Aragon Escobar
- 166
- 1
- 2
- 15
1
vote
3 answers
org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Column with name «name» isn't present in this «ResultSet» Hibernate with PostgreSQL JDBC
As the subject says, I have that error in Hibernate 5 with a PostgreSQL DB.
The query that Hibernate returns to me is:
SELECT u.email, u.password FROM utenti u WHERE u.email = ? (so it's correct)
and the table is:
utenti(email (pk), password, nome,…

cdprete
- 53
- 1
- 9
1
vote
1 answer
NativeQuery is better or HibernateOGM methods
I am using hibernate OGM to talk to my MongoDB instance. I had to get a list of all the products with category "abc". I am using the native query approach to achieve this as following:
String stringQuery = "db.Message.find({'CATEGORY':'" + category…

Obaid Maroof
- 1,523
- 2
- 19
- 40
1
vote
1 answer
Executing a Oracle native query with container managed datasource
I have a project using JPA's in persistence.xml to connect to a container-managed Oracle Datasource, and I have to use in some point a native query that is built dynamically. By default in Oracle I need to specify the schema in…

ViniciusPires
- 983
- 3
- 12
- 26
1
vote
0 answers
JPA native query with mariadb and SqlResultSetMapping throwing a weird error
The relationship:
A company has an address. Thats all I am testing for this simple example.
This is the address entity with the SqlResultSetMappings.
@Entity
@Table(name="addresses")
@SqlResultSetMappings({
@SqlResultSetMapping(name =…

sat
- 5,489
- 10
- 63
- 81
0
votes
0 answers
How convert bytea to smallint in postgres native query
i try to use native query and i get above error: column "code" is of type smallint but expression is of type bytea, does anyone know how to fix it? i tried to use CAST to numeric but it doesn't work.
entityManager.createQuery(
…

pawello12
- 17
- 5
0
votes
1 answer
Why is Hibernate trying to persist @Transient fields causing 'Invalid column name' error?
So i am using Hibernate, and i got this an entity called personAddress, this is an entity that exists on the database, since i am using microservices i use namedQuerys to do the joins, since there are some entities i need to join but i dont have,…