1

こんにちは、バウチャー クラスの単体テストを実行しています。このエラーが発生し続けます。

Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: com.dreamoval.itopup.voucher.model.VoucherType.VoucherCategory in com.dreamoval.itopup.voucher.model.VoucherCategory.voucherTypes
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:708)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:668)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:66)
at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1597)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1355)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)

これはバウチャークラスです

@Entity(name = "voucher")
public class Voucher {

//declaration of variables with their annotations to map attributes of a voucher
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "voucher_id")
private Long voucherId;

@Column(name = "serial_number")
private String serialNumber;

@Column(name = "pin")
private String pin;

@ManyToOne
@JoinColumn(name = "voucher_type_id")
private VoucherType voucherTypeId;

@Column(name = "denomination")
private BigDecimal denomination;

@Column(name = "session_lock")
private Integer sessionLock;

@Column(name = "status")
private String status;

@Column(name = "updated_by")
private String updatedBy;

@Temporal(javax.persistence.TemporalType.DATE)
@Column(name = "expiry_date")
private Date expiryDate;

@Temporal(javax.persistence.TemporalType.DATE)
@Column(name = "last_modified")
private Date dateModified;

@Temporal(javax.persistence.TemporalType.DATE)
@Column(name = "date_entered")
private Date dateEntered;

@OneToOne(cascade = CascadeType.ALL,mappedBy = "Voucher")
private PurchaseHistory purchaseHistory;

/**
* 
* @return voucherId
*/
public Long getVoucherId() {
    return voucherId;
}
/**
 * 
 * @param voucherId the voucherId to be set to
 */
public void setVoucherId(Long voucherId) {
    this.voucherId = voucherId;
}
/**
* 
* @return serialNumber
*/
public String getSerialNumber() {
    return serialNumber;
}
/**
 * 
 * @param serialNumber the serialNumber to be set to
 */
public void setSerialNumber(String serialNumber) {
    this.serialNumber = serialNumber;
}
/**
* 
* @return denomination
*/
public BigDecimal getDenomination() {
    return denomination;
}
 /**
 * 
 * @param denomination the denomination to be set to
 */
public void setDenomination(BigDecimal denomination) {
    this.denomination = denomination;
}
/**
* 
* @return voucherTypeId
*/
public VoucherType getVoucherTypeId() {
    return voucherTypeId;
}
/**
 * 
 * @param voucherTypeId the voucherTypeId to be set to
 */
public void setVoucherTypeId(VoucherType voucherTypeId) {
    this.voucherTypeId = voucherTypeId;
}
/**
* 
* @return dateModified
*/
public Date getDateModified() {
    return dateModified;
}
/**
 * 
 * @param dateModified the dateModified to be set to
 */
public void setDateModified(Date dateModified) {
    this.dateModified = dateModified;
}
/**
* 
* @return dateEntered
*/
public Date getDateEntered() {
    return dateEntered;
}
/**
 * 
 * @param dateEntered the dateEntered to be set to
 */
public void setDateEntered(Date dateEntered) {
    this.dateEntered = dateEntered;
}
/**
* 
* @return expiryDate
*/
public Date getExpiryDate() {
    return expiryDate;
}
/**
 * 
 * @param expiryDate the expiryDate to be set to
 */
public void setExpiryDate(Date expiryDate) {
    this.expiryDate = expiryDate;
}
/**
* 
* @return pin
*/
public String getPin() {
    return pin;
}
/**
 * 
 * @param pin the pin to be set to
 */
public void setPin(String pin) {
    this.pin = pin;
}
/**
* 
* @return status
*/
public String getStatus() {
    return status;
}
/**
 * 
 * @param status the status to be set to
 */
public void setStatus(String status) {
    this.status = status;
}
/**
* 
* @return sessionLock
*/
public Integer getSessionLock() {
    return sessionLock;
}
/**
 * 
 * @param sessionLock the sessionLock to be set to
 */
public void setSessionLock(Integer sessionLock) {
    this.sessionLock = sessionLock;
}
/**
* 
* @return UpdatedBy
*/
public String getUpdatedBy() {
    return updatedBy;
}
/**
 * 
 * @param updatedBy the name to be set to
 */
public void setUpdatedBy(String updatedBy) {
    this.updatedBy = updatedBy;
}

これは ticketCategory クラスです

@Entity
@Table(name = "voucher_category")
public class VoucherCategory {

//declaration of variables for attributes of the voucherCategory.
@Id
@Column(name = "category_id")
private Long categoryId;

@Column(name = "description")
private String categoryDescription;

@Column(name = "name")
private String name;

@Column(name = "update_by")
private String updatedBy;

@Temporal(javax.persistence.TemporalType.DATE) 
@Column(name = "last_modified")
private Date dateModified;


@OneToMany(cascade = CascadeType.ALL,orphanRemoval = true,mappedBy = "VoucherCategory")
private final List<VoucherType> voucherTypes = new ArrayList<VoucherType>();

/**
 * @return the categoryId
 */
public Long getCategoryId() {
    return categoryId;
}
/**
 * @param categoryId  the categoryId to set
 */
public void setCategoryId(Long categoryId) {
    this.categoryId = categoryId;
}
/**
 * @return the categoryDescription
 */
public String getCategoryDescription() {
    return categoryDescription;
}
 /**
 * @param categoryDescription the CategoryDescription to set
 */
public void setCategoryDescription(String categoryDescription) {
    this.categoryDescription = categoryDescription;
}
/**
 * @return the dateModified
 */
public Date getDateModified() {
    return dateModified;
}
 /**
 * @param dateModified the DateModified to set
 */
public void setDateModified(Date dateModified) {
    this.dateModified = dateModified;
}
/**
 * @return the upadatedBy
 */
public String getUpddateBy() {
    return updatedBy;
}
 /**
 * @param updatedBy the UpdatedBy to set
 */
public void setUpddateBy(String updatedBy) {
    this.updatedBy = updatedBy;
}

 /**
 * @return the name
 */
public String getName() {
    return name;
}
 /**
 * @param name the name to set
 */
public void setName(String name) {
    this.name = name;
}

これは ticketType クラスです

@Entity

@Table(name = "voucher_type") public class VoucherType {

//declaration of variables for attributes of the VoucherType,specifying the various fields in the table

@Id
@Column(name = "voucher_type_id")
private long typeID;

@ManyToOne
@JoinColumn(name = "category_id")
private VoucherCategory voucherCategory;

@Column(name = "last_modified")
@Temporal(javax.persistence.TemporalType.DATE)
private Date lastModified;

@Column(name = "picture")
private String voucherImageUrl;

@Column(name = "updated_by")
private String updatedBy;

@OneToMany(cascade = CascadeType.ALL,orphanRemoval = true,mappedBy = "VoucherType")
private final List<Voucher> vouchers = new ArrayList<Voucher>();

/**
 * 
 * @return the typeID
 */
public long getTypeID() {
    return typeID;
}
/**
 * 
 * @param typeID the typeID to set
 */
public void setTypeID(long typeID) {
    this.typeID = typeID;
}
 /**
 * 
 * @return the voucherImageUrl
 */
public String getVoucherImageUrl() {
    return voucherImageUrl;
}
/**
 * 
 * @param voucherImageUrl the voucherImageUrl to set
 */
public void setVoucherImageUrl(String voucherImageUrl) {
    this.voucherImageUrl = voucherImageUrl;
}
/**
 * 
 * @return the lastModified
 */
public Date getLastModified() {
    return lastModified;
}
/**
 * 
 * @param lastModified the lastModified to set
 */
public void setLastModified(Date lastModified) {
    this.lastModified = lastModified;
}
 /**
 * 
 * @return the updatedBy
 */
public String getUpdatedBy() {
    return updatedBy;
}
/**
 * 
 * @param updatedBy the updatedBy to set
 */
public void setUpdatedBy(String updatedBy) {
    this.updatedBy = updatedBy;
}
}


}

これは私のtest-db-config.xmlファイルの内容です

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:jee="http://www.springframework.org/schema/jee"
   xmlns:lang="http://www.springframework.org/schema/lang"
   xmlns:util="http://www.springframework.org/schema/util"
   xmlns:p="http://www.springframework.org/schema/p"
   xmlns:jpa="http://www.springframework.org/schema/data/jpa"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-3.1.xsd   

http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.1.xsd                       

    http://www.springframework.org/schema/lang
   http://www.springframework.org/schema/lang/spring-lang-3.1.xsd 

http://www.springframework.org/schema/util
       http://www.springframework.org/schema/util/spring-util-3.1.xsd 

http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.1.xsd 

http://www.springframework.org/schema/data/jpa  http://www.springframework.org/schema

/data/jpa/spring-jpa-1.0.xsd


http://www.springframework.org/schema/tx">

<context:component-scan base-package="com.dreamoval.itopup.voucher" />
<bean id="propertyConfigurer"
      class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>

            <value>classpath:/META-INF/voucher.properties</value>
        </list>
    </property>
</bean>    

<bean id="dataSource"                             class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="${jdbc.driverClassName}" />
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}"/>
    <property name="password" value="${jdbc.password}" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">   
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>

<bean id="entityManagerFactory"   class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="packagesToScan" value="com.dreamoval.itopup.voucher.model"/>
    <property name="persistenceUnitName" value="defaultPersistenceUnit" />
    <property name="jpaProperties">
        <props>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
            <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
            <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
        </props>
    </property>
</bean>
<bean id="jpdDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect"/>
<jpa:repositories base-package="com.dreamoval.itopup.voucher.repository"/>
</beans>

誰でも私を助けてください...待っています

4

1 に答える 1