2013-05-09 1 views
0

나는 @Converter 사용하는 JPA @Entity 'RecipestepBO'이 : 같은 패키지에은 EclipseLink 내 변환기 클래스를 찾을 수없는

@Entity 
@Converter(name="UnitConverter", converterClass=com.lemcke.share.recipe.Unit.class) 
@Table(name = "recipestep") 
public class RecipestepBO { 
... 
private Unit rpsunit = null; 
... 
@Column(name="rpsunit") 
@Convert("UnitConverter") 
public Unit getRpsunit() { return rpsunit; } 
... 
} 

그리고 컨버터 클래스 (열거 사실이다) :

package com.lemcke.share.recipe; 

public enum Unit implements Converter { 
Liter ("l") 
.... 
all overloaded methods from the Converter 
.... 
} 

다음은 EclipseLink 예외의 애플리케이션 결과 출발 : 글

예외 "메인"javax.persistence.PersistenceException : 예외 [EclipseLink가-28019] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345) : org.eclipse.persistence.exceptions.EntityManagerSetupException 예외 설명 : PersistenceUnit [testPU]의 배포가 실패했습니다. 이 PersistenceUnit의 모든 팩토리를 닫습니다. 내부 예외 : 예외 [EclipseLink-7198] (Eclipse 지속성 서비스 - 2.4.1.v20121003-ad44345) : org.eclipse.persistence.exceptions.ValidationException 예외 설명 : 클래스 : [com.lemcke.share.recipe.Unit] 클래스 이름을 클래스로 변환하는 동안 찾을 수 없습니다.

엔티티는 persistence.xml 파일에 기록됩니다. 변환기 'Unit'은 (엔티티가 아니기 때문에) 아닙니다.

내가 뭘 잘못하고 있니?

답변

1

변환기는 열거 형이 아니라 클래스 여야하며 열거 형이 작동하거나 이해할 수 있어야합니다.

클래스를 시도해 보시고, 여전히 운이 좋다면 전체 예외 스택 추적을 포함하십시오 (이로 인한 경우 포함).

+0

고마워요. 당신 말이 맞아요. 변환기는 어떤 이유에서 건 enum이 될 수 없습니다. –

관련 문제