spring-orm

java.lang.IllegalArgumentException: expecting IdClass mapping

家住魔仙堡 提交于 2019-12-04 22:25:06
I have configured composite primary key for my entity Employee as follows Employee.java: @Entity @Table(name="employee") @Proxy(lazy=false) @IdClass(EmployeeId.class) public class Employee implements Serializable { private static final long serialVersionUID = 1L; private EmployeeId employeeId; private Person person; private Branch branch; private boolean isActive; public Employee() { } @EmbeddedId @AttributeOverrides({ @AttributeOverride(name="person", column = @Column(name="person_id")), @AttributeOverride(name="branch", column = @Column(name="branch_id"))}) public EmployeeId getEmployeeId()

How to Pass Multiple Packages to packagesToScan property in Spring using XML Configuration

一笑奈何 提交于 2019-12-03 06:30:46
问题 Assume i have two packages com.test1 and com.test2 in different modules called M 1 (com.test1) and M2 (com.test2). Now in the following example i configured module1 package. <bean id="entityManager" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="packagesToScan" value="com.test1" /> <property name="dataSource" ref="dataSource" /> <property name="jpaVendorAdapter" ref="hibernateVendor" /> <property name="jpaPropertyMap" ref="jpaPropertyMap" /> </bean

Spring + hibernate versus Spring Data JPA: Are they different?

醉酒当歌 提交于 2019-12-03 03:30:50
问题 Although not novice, I am trying to learn spring framework (again!) in order to be sure that I really understand this. I have got fair idea on core Spring (DI). Now, I am focusing on Data layer. I have come across the term " Spring and Hibernate ". As I can interpret it would mean using Spring Framework with Hibernate as ORM tool/JPA provider. Now I have come across " Spring Data JPA ". I clarified on SO about Spring Data JPA, that it is an abstraction layer on-top of JPA (and under the hood

Why doesn't openSession work but getCurrentSession works in Spring Hibernate

◇◆丶佛笑我妖孽 提交于 2019-12-02 19:51:16
I have written a sample Spring Hibernate application o understand how Spring hibernate integration works. Here is my applicationContext.xml <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation=

Spring + hibernate versus Spring Data JPA: Are they different?

一世执手 提交于 2019-12-02 17:53:47
Although not novice, I am trying to learn spring framework (again!) in order to be sure that I really understand this. I have got fair idea on core Spring (DI). Now, I am focusing on Data layer. I have come across the term " Spring and Hibernate ". As I can interpret it would mean using Spring Framework with Hibernate as ORM tool/JPA provider. Now I have come across " Spring Data JPA ". I clarified on SO about Spring Data JPA, that it is an abstraction layer on-top of JPA (and under the hood Spring Data JPA uses Hibernate or any other JPA provider). Now are these terms same? That is, is "

org.hibernate.WrongClassException on saving an entity via Hibernate

非 Y 不嫁゛ 提交于 2019-12-02 02:48:23
In this question I am working with Hibernate 4.3.4.Final and Spring ORM 4.1.2.RELEASE. I have an User class, that holds a Set of CardInstances like this: @Entity @Table public class User implements UserDetails { protected List<CardInstance> cards; @ManyToMany public List<CardInstance> getCards() { return cards; } // setter and other members/methods omitted } @Table @Entity @Inheritance @DiscriminatorColumn(name = "card_type", discriminatorType = DiscriminatorType.STRING) public abstract class CardInstance<T extends Card> { private T card; @ManyToOne public T getCard() { return card; } } @Table

java.lang.ClassNotFoundException: org.hibernate.engine.SessionFactoryImplementor

杀马特。学长 韩版系。学妹 提交于 2019-11-30 13:41:25
问题 i am trying to migrate to hibernate 4.1.0.Final with spring 3.1.1.RELEASE and following is my configuration for hibernate: <property name="dataSource" ref="dataSource" /> <property name="packagesToScan" value="${project.groupId}.domain" /> <!-- control the behavior of Hibernate at runtime,All are optional and have reasonable default values --> <property name="hibernateProperties"> <value> <!-- hibernate.dialect: allows Hibernate to generate SQL optimized for a particular relational database -

java.lang.ClassNotFoundException: org.springframework.orm.hibernate4.LocalSessionFactoryBean

隐身守侯 提交于 2019-11-30 03:04:16
问题 I'm new to Spring this is my first example (JSF 2, PrimeFaces 3, Spring & Hibernate Integration) here's the pom.xml : <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven- v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>MVNO.ONP.project</groupId> <artifactId>MVNOONPProject</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version>

What is the difference between LocalContainerEntityManagerFactoryBean and LocalEntityManagerFactoryBean?

ぐ巨炮叔叔 提交于 2019-11-29 22:52:10
Can anybody explain what is the difference between the Spring Framework's LocalContainerEntityManagerFactoryBean and LocalEntityManagerFactoryBean ? Basically JPA specification defines two types of entity managers . They are : i) Application-Managed : Application Managed entity manager means "Entity Managers are created and managed by merely the application ( i.e. our code )" . ii) Container Managed : Container Managed entity manager means "Entity Managers are created and managed by merely the J2EE container ( i.e. our code doesn't directly manages instead entity managers are created and

Dynamic datasource in Spring boot JPA

不羁的心 提交于 2019-11-29 12:00:51
I have an application that need to connect to few different schema's but everything of same type (ORACLE). The decision of which schema comes from UI. if User selects schema1, then entity should persist in Schema1, if selects other, then it should be in the selected other schema. Am using Spring boot + Hibernate with the dependency "spring-boot-starter-data-jpa" I have created a datasource class like below so that i can change the "schemaName" in the datasource object everytime before invoking the data layer. @Component public class SchemaDatasource extends AbstractDataSource { private String