I’m trying to create a web application using Spring and Hibernate, deploying it through Tomcat 8. I’ve setup MySQL and Tomcat 8 locally on my machine, and am able to deploy the web application to it. …
Tag: hibernate
How to map an immutable collection with JPA and Hibernate
I am using JPA 2.1 and Hibernate as a JPA implementation, and I want to load a relationship as an immutable collection. Let’s take an example of an Employer parent entity that has an employees child collection. What can be done to instruct JPA to load an immutable employees collection? Answer You can use the @Immutable Hibernate specific annotation: Another
Not supported for DML operations with JPA update query
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 not a query used to select values,
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 this video, are and and InitDbService.java is I have seen this SO Answer, but still getting this error
Hibernate: New Session without dropping the tables
I am new to Hibernate (implementing since yesterday) and i succesfully created a method, that transfers my Customer Objects to the Database. After i quit my application and start it again and create a new session (in an other method) based on my hibernate.cfg.xml file with this setting: It leads to that point, that all relevant tables, created with Hibernate
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 2012 or No Dialect mapping for JDBC type: -9 but
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
Why does Hibernate generate a CROSS JOIN for an implicit join of a @ManyToOne association?
Baur & King said in their book: Implicit joins are always directed along many-to-one or one-to-one association, never through a collection-valued association. [P 646, Ch 14] But when I am doing that in the code it is generating a CROSS JOIN instead of an INNER JOIN. Mapping is from Member2 (many-to-one) -> CLub. But Club2 has no information about members
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 This is my persistence.xml file: This is my Service implementation: And
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: Spring throws org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named ‘persistence.reading’ is defined.