This has been asked once before but the solution did not solve the issue. I am creating a JUnit test: The query the above test is calling is: Error: Answer The @Modifying annotation must be placed on the updateMaterialInventory method, along to the @Query annotation, to let Spring-data know that the query is …
Tag: jpa
object references an unsaved transient instance – save the transient instance before flushing: com.entity.Role
I’m getting object references an unsaved transient instance – save the transient instance before flushing: com.entity.Role exception while trying to insert some values in table using hibernate related dependencies in pom.xml are Role.java is User.java is I’m using repository as mentioned in …
Hibernate with Sql Server fail for nvarchar field with “No Dialect mapping…”
I’m using Hibernate’s JPA-Implementation to access our SQL Server 2012 database. When trying to select a nvarchar field in a native query, I get an exception “No Dialect mapping for JDBC type: -9”. It looks much like No Dialect mapping for JDBC type: -9 with Hibernate 4 and SQL Server …
How configure connection existence check in C3P0?
I am using the below code to get Connection. I have used the c3p0 library for connection pooling. Now my question is, this code is not checking whether the connection is existing or not. Most likely this will get hit by the famous connection closed error after 8 hours. While I was using C3P0 with hibernate, t…
How to specify a Primary Key on @ElementCollection
So, there is that behavior with innodb that can cause problem if some tables lack of primary key. So with Hibernate, I am looking for a key to specifies a primary key on a @ElementCollection table with a Set as the underling data structure. I found a way to have a primary key with a map, but it is kind
Spring JPA no transaction is in progress
I am new to Spring and JPA, wasted 5 days and no result with searching internet. I want to save object to SQL SERVER, connection is correct but when I write .flush() I get the exception nested exception is javax.persistence.TransactionRequiredException: no transaction is in progress This is my jpaContext.xml …
How to inject multiple JPA EntityManager (persistence units) when using Spring
I need to use one database for queries (non-modifying) and one for commands (modifying). I am using Spring Data JPA, so I have two configuration classes: In my repository I sometimes need to decide with EntityManager to use like so: I am using persistence unit’s name as defined in my persistence.xml: Sp…
JPA @Column annotation to create comment/description
I was wondering is it possible to create from jpa/hibernate annotation a database column description/comment like this: ALTER TABLE tablename CHANGE status status INT(11) NOT NULL COMMENT ‘sample description/comment’; It will be great functionality, but I cant find anything about this in JPA speci…
Spring boot JPA insert in TABLE with uppercase name with Hibernate
i have a table entity mapped as : When i try to insert new record in database, the table name was translated in lowercase as : items_to_register , but my table name is ITEMS_TO_REGISTER How can i fix my problem without change MySql configuration? (my.cnf) I have in my application.properties file : Answer On h…
EclipseLink Query – Select count(*) from student s not working
I am getting following exception :- [13, 13] The left expression is missing from the arithmetic expression. [14, 14] The right expression is missing from the arithmetic expression. Please help me analyse the problem. P.S. If I replace the above query in my code with select * from student s, it is working fine…