Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
48 views

Why do I get 'java.lang.IllegalArgumentException: Not an entity' from hibernate using criteria API

I am trying to wire hibernate into an old project (java8, hibernate 5.6.5) but keep getting "Not an entity" in my first tests. This is when using the Criteria API. The problem occurs at the ...
Mario Daglio's user avatar
1 vote
1 answer
67 views

Deadlock on SQL Server only when running database locally

When trying to test locally an application (Java, Spring boot, hibernate, SQl server as database) i notice a significant amount of deadlock, the application and the database are running on my computer ...
Benoit's user avatar
  • 45
0 votes
0 answers
71 views

Preload database tables and its join tables when we are using Hibernate GenerationType.IDENTITY

I'm using Quarkus with Panache and Hibernate 6, and SQL Server. Our entities are using GenerationType.IDENTITY. We need to preload the database before to start the application. At dev we are using a ...
Cristiano's user avatar
  • 1,763
0 votes
1 answer
147 views

Request processing failed: org.springframework.dao.InvalidDataAccessResourceUsageException JDBC exception executing SQL Invalid column name 'd'

I am building Spring boot rest application, I am using SQL server 2022, my application get data from DB which created desktop application which is using SQL Server, and I can not change any column ...
Ruslan Şirbidov's user avatar
0 votes
0 answers
45 views

What is the advantage of using StringNVarcharType over StringType for mappings to columns of type NVARCHAR?

Hibernate seems to work equally well with columns of type NVARCHAR when using either StringNVarcharType or StringType for mapping. Using StringType, which is the default, seems to offer some ...
01es's user avatar
  • 5,410
1 vote
1 answer
128 views

Hibernate results loading stuck in middle of a row

When querying SQL Server database from Spring Boot JPA using a native query it takes longer than expected. On trace level it's visible that it's stuck when parsing a single row. Jump in time is ...
Jakub Havlík's user avatar
-2 votes
1 answer
69 views

Hibernate forces foreign key to be non-null

I want a Product to have an optional ProductType. But during schema generation, Hibernate for some reason ignores my definition and creates a non-nullable column for a foreign-key. We are using ...
Japu_D_Cret's user avatar
1 vote
1 answer
209 views

Ordinal enum mapping with Hibernate 6.5

I'm upgrading Hibernate from 6.1.7 to 6.5.2, there are many enum columns in my entities marked with @Enumerated(EnumType.ORDINAL). My codebase has to run against both Oracle and SQL Server. The ...
viliam's user avatar
  • 513
0 votes
2 answers
88 views

SQL like query contains only a specific character

I'm trying to get records from SQL server starting with abc_ followed by at least one letter (a-z, A-Z) and then continue to the end with just letters and numbers (a-z, A-Z, 0-9). No special ...
AdamN's user avatar
  • 1
0 votes
0 answers
20 views

How FetchType.EAGER and FetchType.LAZY works in JPA/Hibernate

I am new to Java EE, using Spring Boot, JPA and Hibernate. I have two entities, Game and Genre with ManyToMany relationship here. Game: @Data @Entity @Table(name = "games") public class ...
Le Trong Hung FPL HCM's user avatar
0 votes
0 answers
69 views

Issue with @GeneratedValue and SequenceStyleGenerator on SQL Server 2019/2022 with Hibernate 6.4.4

We are using 4 database: Oracle, SQL Server 2019 & 2022, and MySQL Hibernate:6.4.4 @Id @GenericGenerator( name = "sequenceGenerator", type = SequenceStyleGenerator....
Yusuf BESTAS's user avatar
0 votes
0 answers
23 views

Read-replica SpringBoot Hibernate [duplicate]

I want to distibute my consults in my BD-01 in my another BD-02, those are the same with the same data (Microsoft SQL Server Enterprise), however the consults on my application only directs to my BD-...
Eric Borges's user avatar
0 votes
1 answer
47 views

Error when saving link table: Cannot insert the value NULL into column 'ParentId', table 'TableParentChild'; column does not allow nulls. INSERT fails

I'm writing an import and need to save two types of data (parent & child) to their respective tables and a link table (parentChild) to join them up. I know the error is pretty self explanatory and ...
damanara's user avatar
1 vote
0 answers
35 views

Handling exceptions when calling stored procedures in hibernate

I'm currently using hibernate and I have this piece of code in java: ProcedureCall pc = session.createStoredProcedureCall("sp_test"); pc.getOutputs() Stored procedure in SQL Server: ...
Kiều ZzTrung's user avatar
1 vote
0 answers
33 views

Cannot insert explicit value for identity column in table 'EmailMessageTemplate' when IDENTITY_INSERT is set to OFF

I have an issue after I upgrade hibernate in my application from 5.x to 6.x. I am getting the following error could not execute batch [Cannot insert explicit value for identity column in table ‘...
sundar saba's user avatar
1 vote
2 answers
196 views

How to configure NHibernate to connect to SQL Server?

I am facing a little problem with my NHibernate configuration connection with SQL server database. My App structure is just for simple test. Here is my hibernate.xml.cfg: <?xml version="1.0&...
Oussema's user avatar
  • 33
0 votes
1 answer
341 views

Date criteria not working in Spring boot criteria builder

I am applying a date criteria in my Java Springboot project through criteria builder but it's not working. All the records are being fetched and the conditioning on date is getting ignored. Session ...
Parth Atara's user avatar
0 votes
0 answers
43 views

Column names auto conversion not done

The automatic mapping between entity attributes being in lowercase and table attributes being in snake case is not done thus throwing the following exception. com.microsoft.sqlserver.jdbc....
Paul's user avatar
  • 1,041
0 votes
1 answer
91 views

Opposite of @Nationalized hibernate annotation

I am looking for the opposite of @nationalized hibernate annotation. When specifying spring.jpa.properties.hibernate.use_nationalized_character_data =true nationalization is the default behaviour, but ...
Thomas's user avatar
  • 1,134
0 votes
1 answer
40 views

Save Multiple entities having one to many mapping cause dynamic db calls

Let two entities: School (id, name) and Student (id, name, SchoolId). There is one to many mapping from student to school. For Saving list of students in Spring boot: public void saveStudents(List<...
Zulker Nayeen's user avatar
0 votes
1 answer
65 views

SqlRowSet throws Invalid SQL type for column with dateTimeOffset(Type associated with java Instant)

I have upgraded my application to Springboot 3(Hibernate 6) and now instant is stored as datetimeoffset in sql server. I have several queries which returns last modified date and created date using ...
aakash singh's user avatar
0 votes
0 answers
55 views

getTypeName method when updating from Hibernate core v5 to v6

My application has CustomDialect extending SQLServerDialect. I'm trying to update this application dependencies hibernate-core from v5 to v6. My custom Dialect looks something like this: CustomDialect ...
Thrilok's user avatar
  • 111
0 votes
0 answers
102 views

Correct way to add default value at database level with Hibernate 6 and Spring boot 3

I have columns on which I require default value at DB level. Before hibernate 6, hibernate never fired alter query to change DB or alter length. The problem is we used to write default keyword with ...
aakash singh's user avatar
0 votes
1 answer
1k views

Spring JPA generated query taking way longer to run than it should

I have a table in my DB mapped to one entity in my project. I'm trying to perform a simple select using findById() based on the PK's of this entity. This table has 48 million rows, so it's a very ...
Gustavo Cesário's user avatar
0 votes
0 answers
59 views

Lock On Insert in Sql Server

I am using the following code to insert in database: Employe emp1=new Employe (); emp1.setId(12) .getCurrentSession().saveorUpdate(emp1) .getCurrentSession().flush() Employe emp2=new Employe (); emp2....
Ali Khalil's user avatar
1 vote
0 answers
332 views

Spring uses varchar with @Nationalized annotation if the value is null

I have just updated my Spring Boot project from 2.1.7.RELEASE to 2.7.10. I use SQL Server database where some of columns encrypted using Always Encrypted (via Java Keystore). Before the update ...
bowling's user avatar
  • 33
1 vote
1 answer
581 views

Schema validation fails with Hibernate 6 and ZonedDateTime and colum type timestamp with SQL Server and hibernate.timezone.default_storage

We have migrated an existing spring boot application to Spring 3.2.1 with Hibernate 6.4.1 (using SQL Server and PostgreSQL as persistency variants). When starting the application, we get now following ...
D. Kellenberger's user avatar
0 votes
0 answers
59 views

Pessimistic locking is not running as expected when running from another thread

I'm using Spring Boot 3 with SQL server which seems to have isolation level as read committed. I'm expecting to see here an exception in main thread but I'm not getting any. Not sure what seems wrong. ...
darthwader's user avatar
0 votes
0 answers
30 views

Springframework SQLServerException: Invalid object name (database table name) [duplicate]

In springframework I have a repository for questioning the database and a Entity with controller. But when I make a query the following error appears: SQLServerException: Invalid object name '...
Jean Boumans's user avatar
0 votes
2 answers
182 views

Why does using hibernate query .setParameter() + openjson() improve sql server query performance over .setParameterList()?

I have a complex SQL Server query that needs to process around 2000 parameters at a time. My query is complex, so for simplicity suppose we have: select * from sample_table where id in (:listIds); In ...
jk101's user avatar
  • 25
0 votes
1 answer
75 views

HQL and/or SQL Server a performance issue

I have some difficulty understanding performance issues of Hibernate in conjunction with SQL Server. My very sophisticated HQL Query with 16 joins and 41 parameters in the where clause looks something ...
Mr.H.'s user avatar
  • 1,025
-1 votes
1 answer
1k views

Unable to connect to SQL Server via Java SpringBoot application

I am trying to just get the thing running and part of that involves connecting to SQL. I'm using SQL Server Express and I've attached a picture of my connection information below just in case you find ...
asymmonds's user avatar
0 votes
0 answers
26 views

Select in Hibernate has same duration with or without statistics

I currently have an abnormally slow simple SELECT. I find it slow because it just does : SELECT * from myTable where idNonIndex1 = 1 and idNonIndex2 = 2 The cause of the slowness could have been the ...
Werehog83's user avatar
0 votes
0 answers
302 views

Invalid object name using native query with hibernate

I am trying to use @Query to do nativeQuery using JPA, so I wrote this: @Query(value = "SELECT TOP (?1) stg.*, a.alias " + "FROM EVENTS_TABLE e WITH (UPDLOCK, ROWLOCK, ...
Newkstron's user avatar
0 votes
0 answers
109 views

Join alias not used into CASE WHEN on SELECT close

Consider these three entities: @Entity public class EntityA { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; @JoinColumn(updatable=false, name="...
asyncmind's user avatar
  • 415
1 vote
1 answer
338 views

Query in SQL Server giving error while running the same query with MySql working fine

I have the following query, and executing through hibernate. String userIdQueryString = "select distinct user_id from l_catalog_user_object_access where REPORT_HEADER_ID in (" ...
purush's user avatar
  • 359
0 votes
0 answers
652 views

What is the efficient way to send large IN clause in JPA/Hibernate

I'm trying to send in large IN clause (possibly in thousands) in a Criteria Query using JPA and the query has reached its limit and ran out resources in SQLServer (error 8623). The query processor ...
Sivaram Kumar's user avatar
1 vote
2 answers
97 views

Confused about hibernate in spring mvc

i'm very new in spring mvc and struggling with hibernate now. I can extract data from ms sql server but the length of string is always to set maximum to field (add duplicate backspace character i ...
Daniel's user avatar
  • 23
1 vote
1 answer
270 views

Unexpected row count: -1; expected: 1 with Spring Data JPA SQL Server with NOCOUNT ON

PROBLEM: I am having a problem regarding the database under the server in SQL Server which has Server Property > Connection > NOCOUNT ON (is ticked). The table has no trigger, absolutely nothing ...
infD's user avatar
  • 63
0 votes
0 answers
156 views

Pagination with distinct clause using hibernate and SQL Server

I am creating a pageable query over SQL Server using JPA with Spring Data using this repository call: @Query("select distinct nat from TABE1 nat " + "left join TABLE2 ...
knoppix's user avatar
  • 166
0 votes
0 answers
231 views

Problems while trying to connect to database Hibernate

I'm trying to connect to database and my request had to create a table and add values to it. I'm using Microsoft SQL Server Management Studio and i created a database named "itstep" in ...
Максим's user avatar
0 votes
0 answers
64 views

Runtime exceptions when trying to migrate from MySQL to MS SQL Server

I have a spring boot application(https://github.com/khandelwal-arpit/springboot-starterkit-mysql)that works fine when I use a MySQL database and configuration. However I want to migrate to MS SQL ...
Jaiylon's user avatar
  • 185
0 votes
0 answers
4k views

How to configure connection between Spring boot application and MS SQL Server?

I am trying to change my database from MySQL to MS SQL Server in order to use live update in Microsoft Power Bi, however, I am having some issues when trying to create the configuration for the ...
Jaiylon's user avatar
  • 185
0 votes
0 answers
98 views

Spring JPA randomly suspends insert and goes in endless wait

I am calling a @Transactional method with a rollback on JPA for Exception.class. This function makes various inserts and selects successfully and also calls 2 SPs in sqlserver in different scenarios, ...
Nutan's user avatar
  • 1,355
1 vote
0 answers
318 views

hibernate: Row level security - set session context properties and pass to MS SQL

In my java based application I want to make use of RLS in MS SQL. For this, I created a security policy with a function, which expects a tenantId in the session context and filters data for this ...
i89's user avatar
  • 1,112
2 votes
1 answer
542 views

How should we handle id on Hibernate 6 on Sql server

We are migrating from Hibernate 5 to 6, and are having issues with the conversion of our id. @MappedSuperclass public abstract class Entity { @Id @Column(name = "ID") @Convert(...
Ingvild Ødegård's user avatar
2 votes
1 answer
1k views

Performance issue in Spring Boot Java app with SQL Server

I am facing performance issues with a Spring Boot Java App which gets data from a SQL Server database. A simple query like: SELECT a, b, SUM(c) FROM table WHERE date = '2023-02-01' AND year = 2023 ...
sebk's user avatar
  • 127
0 votes
1 answer
392 views

Why does JDBC return no results from a stored procedure?

I call a stored procedure using JDBC: Connection con = DriverManager.getConnection("jdbc:sqlserver://myhost;databaseName=mydb;encrypt=false","user", "pass"); ...
James's user avatar
  • 3,174
0 votes
1 answer
218 views

How to get next id for ID generation strategy = GenerationType.TABLE

Is there an easy way to get the next id of an object which use id generation strategy GenerationType.TABLE and a custom database table? My problem is that allocation size is not 1 (which is fine - ...
Dzhenko's user avatar
0 votes
0 answers
64 views

Version number of new entity is equal to 1 after first save

I'm really confused about saving new entity to repository. Firstly I check repo.findAll() to see element inside, and lets say there is one element there. Then, I save entity like SomEntity(id=1, ...
ezjdmoq's user avatar

1
2 3 4 5
22