开发者

org.hibernate.MappingException using annotations

开发者 https://www.devze.com 2022-12-19 05:42 出处:网络
I am using JPA annotations for these two classes: @Entity @RooJavaBean @RooToString @RooEntity @MappedSuperclass

I am using JPA annotations for these two classes:

@Entity
@RooJavaBean
@RooToString
@RooEntity
@MappedSuperclass
public abstract class BaseEntity {

  @Temporal(TemporalType.TIMESTAMP)
  @DateTimeFormat(style = "S-")
  private Calendar created;

  @Temporal(TemporalType.TIMESTAMP)
  @DateTimeFormat(style = "S-")
  private Calendar updated;

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = "id")
  private Long id;

  @Version
  @Column(name = "version")
  protected Integer version;

  public Long getId() {
  return id;
  }

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

  public Integer getVersion() {
  return version;
  }

  public void setVersion(Integer version) {
  this.version = version;
  }

  @PrePersist
  protected void onCreate() {
  created = Calendar.getInstance();
  }

  @PreUpdate
  protected void onUpdate() {
  updated = Calendar.getInstance();
  }

}
@Entity
@RooJavaBean
@RooToString
@RooEntity
public class Event extends BaseEntity {

  private Score challenger;
  private Score defender;
  ...
}

@Entity
@RooJavaBean
@RooToString
@RooEntity
public class Score extends BaseEntity {

  @ManyToOne
  private Team team;
  private Event event;
  private Integer score;
  private Boolean accepted;
}

I get an exception though:

Caused by: org.hibernate.MappingException: Could not determine type for: edu.unlv.cs.ladders.entities.Score, at table: event, for columns: [org.hibernate.mapping.Column(challenger)]
 at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:269)
 at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
 at org.hibernate.mapping.Property.isValid(Property.java:185)
 at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:440)
 at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
 at org.hibernate.cfg.Configuration.validate(Configuration.java:1108)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1293)
 at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
 at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)

Does this have to do with having two separate fields that access the same class? Do I have to be more descriptive and specif开发者_JS百科y column names or something?


You need to annotate the Score properties with ManyToOneor OneToOne.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号