spring-orm

java.lang.IllegalArgumentException: expecting IdClass mapping

孤人 提交于 2019-12-22 01:32:56
问题 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")),

NoUniqueBeanDefinitionException: No qualifying bean of type [javax.persistence.EntityManagerFactory] is defined: expected single matching bean

隐身守侯 提交于 2019-12-20 12:33:46
问题 I have 2 separate databases and I am trying to access them in repositories. Unfortunately I am receiving the following exception. Things I have tried have tried making one of the bean as Primary . have used PersistenceContext as can be seen in code below. My ExceptionTrace Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orderController': Injection of autowired dependencies failed; nested exception is org.springframework.beans

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

霸气de小男生 提交于 2019-12-20 09:46:01
问题 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

Dynamic datasource in Spring boot JPA

不问归期 提交于 2019-12-18 05:23:10
问题 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

Unable to build Hibernate SessionFactory when using Joined inheritance

廉价感情. 提交于 2019-12-13 02:56:01
问题 I have a class that defines an InheritanceType.JOINED from which a couple more classes inherit from: BaseClass @Entity @Inheritance(strategy = InheritanceType.JOINED) @DiscriminatorColumn(name = "DISCRIMINATOR") @Table(name = "BASE_CLASSES", uniqueConstraints = @UniqueConstraint(columnNames = { "DISCRIMINATOR", "NAME" })) @Cacheable @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class BaseClass implements Serializable { private static final long serialVersionUID = 1L; @Id

conflict with spring-orm 3.2.3 NoClassDefFoundError

瘦欲@ 提交于 2019-12-11 19:25:27
问题 Im trying to make a simple spring mvc + hibernate to test a basic form. im trying to use LocalSessionFactoryBean. The problem it's that each time I import the maven dependency spring-orm 3.2.3 for the LocalSessionFactoryBean it rises the next problem: java.lang.NoClassDefFoundError: org/springframework/beans/factory/NoUniqueBeanDefinitionException at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2451) at java.lang.Class

HibernateTemplate in spring orm 4.0.6 is missing saveOrUpdateAll

…衆ロ難τιáo~ 提交于 2019-12-11 10:43:11
问题 I am trying to migrate our app from spring 2.5.6 to recent version of spring which is 4.0.6. One of the issues I faced is HibernateTemplate is missing saveOrUpdateAll. I could change it manually but I need to change it close 200 files. I don't know why Spring removed it instead of deprecating it. Anyone have workaround for this? I believe this is the starting of painful migration. 回答1: From Spring 2.5 to 4.0 is quite a big jump. And Spring DID deprecate that method. If you look at the API for

Strange exception on inital request to Repository when using Spring Data JPA with EJB/CDI

故事扮演 提交于 2019-12-11 07:15:57
问题 I've created a small project which combines Spring Data, a JPA Repository, EJB/CDI and either Wildfly Swarm or plain Wildfly. The REST resource (an EJB) calls a CDI bean which has a Spring Data JPA Repository injected. The initial request to the repository ends in an exception, but subsequent calls work just fine. 2016-12-15 23:03:09,690 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-1) SQL Error: 0, SQLState: null 2016-12-15 23:03:09,690 ERROR [org.hibernate.engine

org.hibernate.MappingException: Unknown entity: in spring orm

丶灬走出姿态 提交于 2019-12-08 06:17:11
问题 I am getting following exception org.hibernate.MappingException: Unknown entity: com.sample.Student I have seen so many answers to same question on Stackoverflow but all of them suggests to use @Entity annotation from javax.persistence instead of hibernate, in my case I am using it from javax.persistence only but still getting this exception. my POJO class package com.sample; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table public

No transaction in progress exception with Spring 3.1 and JPA 2

不问归期 提交于 2019-12-05 17:20:35
I have been at this for weeks. I have tried eclipselink and now just plain JPA. I keep getting the same issue. Everytime I try to flush my entity manager I get 'javax.persistence.TransactionRequiredException: no transaction is in progress' exception. I know its something to do with how I have everything wired but I can't figure it out. I have tried writing JUnit tests to test, but since I am new to spring that has a entirely different set of issue. Some things to note: I am not using a persistence.xml since I am using spring 3.1 * App Server: WebSphere 8.5 (Liberty Profile) * exception [ERROR