문제

현재 "NoFollow noreferrer"> UserType 를 사용하여 Hibernate에서 Joda 시간을 유지하려고합니다. 그러나 다음을 계속 지키고 있습니다.Eclipse의 오류.

오류 메시지

(failed.org.hibernate.mappingException : org.jadira.usertype.dateandtime.jsr310.persistentlocaldateTime, art : [org.hibernate.mapping.column (modified_date_time)])

내 XML 파일은 다음과 같습니다

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ibernate-mapping PUBLIC 
"-//Hibernate/Hibernate Mapping DTD 3.0//EN" 
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="model" >
    <class name="ModelObject" table="MODEL_OBJECT">
        <id name="id" column="MODEL_ID" >
            <generator class="native"></generator>
    </id>
    <property name="modifiedDateTime"             
            type="org.jadira.usertype.dateandtime.jsr310.PersistentLocalDateTime"
            column="MODIFIED_DATE_TIME"/>
        <property name="creationDateTime"
            type="org.jadira.usertype.dateandtime.jsr310.PersistentLocalDateTime"
            column="CREATION_DATE_TIME"/>
    </class>
</hibernate-mapping>`
.

및 My Java 파일은 다음과 같습니다

package model;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import org.joda.time.LocalDateTime;

public abstract class ModelObject  {

private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);

private long id;
private LocalDateTime  modifiedDateTime = new LocalDateTime ();
private LocalDateTime  creationDateTime = new LocalDateTime ();

public Long getId(){
    return id;
}

public void setId(Long id){
    firePropertyChange("id", this.id, this.id = id);
}

public LocalDateTime  getModifiedDateTime(){
    return modifiedDateTime;
}

public void setModifiedDateTime(LocalDateTime  modifiedDateTime) {
    firePropertyChange("modifiedDateTime", 
                this.modifiedDateTime, 
                this.modifiedDateTime = modifiedDateTime);
}

public LocalDateTime  getCreationDateTime(){
    return creationDateTime;
}

public void setCreationDateTime(LocalDateTime  creationDateTime){
    firePropertyChange("creationDateTime", 
                this.creationDateTime, 
                this.creationDateTime = creationDateTime);
}

public void addPropertyChangeSupportListener(PropertyChangeListener listener){
    changeSupport.addPropertyChangeListener(listener);
}

public void removePropertyChangeListener(PropertyChangeListener listener){
    changeSupport.removePropertyChangeListener(listener);
}

public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener){
    changeSupport.addPropertyChangeListener(propertyName, listener);
}

public void removePropertyChangeListener(String propertyName, 
                                             PropertyChangeListener listener){
    changeSupport.addPropertyChangeListener(propertyName, listener);
}

protected void firePropertyChange(String propertyName, Object oldValue, Object newValue){
    changeSupport.firePropertyChange(propertyName, oldValue, newValue);
}

}
.

i Usertype.spi-3.0.0.jar 및 usertype.core.3.0.0.0.CR3.jar를 클래스 경로에 추가했습니다.

여기서 무슨 일이 일어나고 있는지 전혀 모르겠으므로 도움이 될 것입니다

도움이 되었습니까?

해결책

HBM 사용자 정의 유형과 별도의 파일 추가
CustomTypes.hbm.xml

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="com.softcomputer.softlab.business.core">
   <typedef name="localJodaDate"
      class="org.jadira.usertype.dateandtime.jsr310.PersistentLocalDateTime" />
</hibernate-mapping>  
.

이 파일을 맵핑 에 포함시킵니다.

  <mapping resource="CustomTypes.hbm.xml" />
.

다른 팁

문제는 JODA 시간 유형이 아닌 JSR 310 유형 (Threeten의 경우)을 사용하고 있다는 것입니다.

org.jadira.usertype.dateandtime.jsr310.persistentLocalDateTime을 org.jadira.usertype.dateandtime.joda.persistentLocalDateTime 및 문제 해결해야합니다.

Chris 에 포함됩니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top