* @Repository 에 페이징 포함된 find 정의를 다음과 같이 함. Page findByPp(PostPlace pp, PageRequest of); 실행시 다음오류 발생 java.lang.IllegalArgumentException: At least 2 parameter(s) provided but only 1 parameter(s) present in query. * 해결 find 메서드 정의 당시 PageRequest 아닌 Pageable 로 정의해야 함. Page findByPp(PostPlace pp, Pageable of);
* SessionFactory(SF) 를 EntityManager(EM) 로 부터 가져온 후 이 SF 로 부터 가져온 세션으로는 Session#update() 가 실행은 되지만 실제로 DB 반영은 이루어지지 않음. 별다른 오류메시지는 없음. * Session#flush() 를 해야 DB 에 반영이 되나 싶어 추가시키자 다음 오류 발생 org.springframework.dao.InvalidDataAccessApiUsageException: no transaction is in progress; nested exception is javax.persistence.TransactionRequiredException: no transaction is in progress * 해결 ] SessionFactory..
* 개요 Hibernate 3 에서 쓰던 코드를 Spring 5 , JPA , Spring boot 환경으로 가져오는 중 DAO 에서 HibernateDaoSupport 를 버전 5로 import 바꾼 후 (다 됐다고 생각했는데) 실행시켰는데 오류 남. Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.hibernate.SessionFactory' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} * 환경 Spring 5 Spring..
org.hibernate.WrongClassException: Object with id: 1289153 was not of the specified subclass: XXXX (Discriminator: XXX) * 개요 entity A가 있고, 이를 상속하는 B가 있음. B를 선언시는 @DiscriminatorValue("XXX") 를 함께 선언해줘야 함. 저장되는건 A,B 모두 A의 테이블에 저장됨 B 클래스를 다른 패키지로 옮기고 나서 조회시 위의 오류가 발생함. * 원인 검색해보니 A,B가 각기 다른 테이블을 사용하면서 ID 를 동일한 값을 가지는 경우 문제가 될 수 있다고 함. 그러나 나의 경우 아니었음 (둘다 A 테이블을 공유함) * 해결 A 테이블 모든 값 지우고 시작하니 문제 없었음. (..
* 개요org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 * 상황 1 - getHibernateTemplate().delete(..) 실행중 발생 - 원인DB 에 존재하지 않는 Entity 를 삭제 시도시 발생 - 참고https://stackoverflow.com/questions/2743130/hibernate-batch-update-returned-unexpected-row-count-from-update-0-actual-row - 해결먼저 get(..) 으로 특정 PK 로 찾아본 후 null 아닐때만 삭제하도록 로직 변경 ..
* 오류 로그.......... Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The driver was unable to create a connection due to an inability to establish the client portion of a socket. This is usually caused by a limit on the number of sockets imposed by the operating system. This limit is usually configurable. For Unix-based platforms, see the manual page for the 'ulimit' command. Ke..
* ArrayStoreException 원인https://stackoverflow.com/questions/50785468/java-lang-arraystoreexception-when-assigning-value-with-incorrect-type-to-objecObject x[] = new String[3];x[0] = new Integer(0); 1. Object[] 배열 선언2. Object[] 에 String[] 로 배열 생성3. String[] 의 요소로 Integer 대입 * 참고 : 배열 사용시 ClassCastExceptionString[] as = (String[]) new Object[3]; * 하이버네이트에서 ArrayStoreException1. SQLQuery 로 데이터 불러옴2..
* 개요SQLQuery q = ...q.setParameter(enum값) 코드가 있었음 결과가 안 나오는 문제. * 원인- mysql 에 보내진 쿼리를 확인해 보니 다음과 같았음( 참고 : mysql 쿼리 보는 법 http://dogcowking.tistory.com/246) 2018-10-24T10:09:14.815899Z 60 Query/* dynamic native SQL query */ select .... 중략 .....where mType = x'ACED00057E72002B636F6D2E6369646F672E636F6E6372657465696E666F2E6D6F64656C2E436953656374696F6E245479706500000000000000001200007872000E6A61766..
* 개요 Class Lion { ...@Embeddablepublic static class Animal implements Serializable{Long feet; ...} @Embeddedpublic Animal animal = new Animal() ; } 위 처럼 내부 클래스 정의하여 사용 가능한가? * 결론 : 가능 https://stackoverflow.com/questions/27745374/inner-class-as-hibernate-component - 불가능하단 의견 있었으나, 실험시 동작함 - 내부클래스에 @Embedable클래스 속성 선언시 @Embedded 선언시 가능 * 참고 : Embedded 사용법https://www.concretepage.com/hibernate/exam..
* 오류 내용 org.springframework.dao.InvalidDataAccessResourceUsageException: could not insert: [com.cidog.bbs.model.BbsRank]; SQL [insert into bbsrank (type1, type2, type3, typeLong1, rank, cnt, ranker, rankerLong) values (?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is org.hibernate.exception.SQLGrammarException: could not insert: [com.cidog.bbs.model.BbsRank]at org.springframework.orm.hibernate3.Ses..
Class Clr {...@ElementCollectionpublic List cioIds; ...} * 개요1. clr1 이 있음. cioIds는 Clr_cioIds 란 테이블로 별도 저장됨. 2. clr2 를 생성clr2.cioIds = clr1.cioIds 3. clr2 를 저장 - 결과 : clr2 의 cioIds 는 정상적으로 저장되지만,원본인 clr1 의 cioIds 가 삭제됨 * 문제해결clr2.cioIds =... 형식 대신clr2.setCioids(clr1.cioIds) 로 대입함. - cioIds 단순한 Long 이지만, Hibernate 안 에서는 Proxy 객체인듯함.저장시 set 함수 아닌 그대로 대입시에는 clr1 의 객체를 가져다쓰게 되어서해당 Long 객체의 주인이 clr1 ..
ERROR: org.hibernate.id.enhanced.TableStructure - could not read a hi valuejava.sql.SQLSyntaxErrorException: Table '130514cidogir.hibernate_sequence' doesn't exist * 오류 원인@Id 선언을 auto 로 했다면, 하이버네이트가 자체적으로hibernate_sequence테이블 가지고 있으면서 ID 를 생성해줌이때 이 테이블을 삭제하면 발생하는 오류 @GeneratedValue(strategy=GenerationType.AUTO) * 해결- 해당 테이블을 만드는 방법도 있겠지만... @Id@GeneratedValue(strategy=GenerationType.IDENTITY) pu..
org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: 클래스명 * 원인A클래스가 B에 대한 FK 를 가지고 있음. (OneToOne) SELECT FROM A WHERE A.B_ID = ?실행시 Restrictions.eq("B_ID", B객체) 해야 함. B객체를 ID값만 임의 지정한 임시객체를 만들어서 넣었기 때문이었음. * 해결B객체를 DB로부터 직접 불러와서 사용( ex : Restrictions.eq("B_ID", findB(B의ID)) ) * 다른 해결책http://cpdev.tistory.com/85 @On..
Session s= getSession();Criteria c = s.createCriteria(CiClst.class);c.add(Restrictions.in("clrId", clrIds));List r = c.list();s.close(); java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long * 원인clrIds 가 Hibernate - SQL 통해 가져온 리스트였고, SQLQuery 통해 가져온 것.- (Criteria나 Query 가 아닌... ) SQLQuery 로 가져올 경우 Long 이 아닌 BigInteger 로 가져오게 됨.- 이걸 Long 으로 바꿔서 리스트에 넣었어야 했는데, 그렇지 않음...
*넣어도 같음 * org.springframework.transaction.annotation.Transactionaland not javax.transaction.Transactional.https://stackoverflow.com/questions/25821579/transactionrequiredexception-executing-an-update-delete-query?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa 바꿨으나 같아 *transaction = session.beginTransaction(); int result = query.executeUpdate(); transaction.commit(); 성공 ..
*tx:annotation-driven" 요소에 대한 "tx" 접두어가 바인드되지 않았습니다. org.xml.sax.SAXParseException; lineNumber: 28; columnNumber: 54; cvc-complex-type.2.4.c: 일치하는 와일드 카드 문자가 엄격하게 적용되지만 'tx:annotation-driven' 요소에 대한 선언을 찾을 수 없습니다. *
* 환경MySQL 8 Hibernate 5 * 오류 1hibernate SQL Error: 0, SQLState: 08001 javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection ... com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server..... java.lang.NullPointerExceptioncom.mysql.jdbc.ConnectionImpl.getServerCharacterE..