我正在尝试使用Play Framework JPA连接到现有的Sybase数据库。
@Entity
@Table(name="trade")
public class Trade extends GenericModel
{
@Id
@Column(name="SYB_IDENTITY_COL", nullable=false, precision=10)
public long sybIdentityCol;
@Column(name="trade_number", nullable=false, precision=18)
public long tradeNumber;
@Column(name="trade_price", nullable=false, precision=16)
public double tradePrice;
.
.
.
@ManyToOne
@JoinColumn(name="book_id", referencedColumnName="SYB_IDENTITY_COL")
public Book book;
}
@Entity
@Table(name="book")
public class Book extends GenericModel
{
@Id
@Column(name="SYB_IDENTITY_COL", nullable=false, precision=10)
public long sybIdentityCol;
@Column(name="book_code", nullable=false, length=4)
public String bookCode;
.
.
.
.
}
当我从控制器调用以下函数时,JVM挂起:
Trade trade = Trade.findById(209115258L);
但是,当我删除ManyToOne映射并使用JPQL加入
时,一切正常 Query query = JPA.em().createQuery("select b from Trade t, Book b where t.bookId = b.sybIdentityCol and t.sybIdentityCol=209115258");
List<Book> books = query.getResultList();
我使用org.hibernate.dialect.Sybase11Dialect
作为JPA Dialect。我不明白为什么ManyToOne映射不起作用。