开发者

ManyToOne Mapping using play GenericModel

开发者 https://www.devze.com 2023-03-13 00:22 出处:网络
I am trying to connect to an existing Sybase database using Play Framework JPA. @Entity @Table(name=\"trade\")

I am trying to connect to an existing Sybase database using Play Framework JPA.


@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;
        .
        .
        .
        .
}

The JVM hangs when I call the following function from the controller:

       Trade trade = Trade.findById(209115258L);

But, everything works fine when I remove the ManyToOne mapping and join using 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();

I am using org.hibernate.dialect.Sybase11Dialect as the JPA Dialect. I don't underst开发者_StackOverflowand why the ManyToOne mapping is not working.

0

精彩评论

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