Java Persistance: Question about query within inheritance class
In father class here is the annotation:
@Entity
@Table(name = "CONTENT_MEDIA")
@Inheritance(strategy=javax.persistence.InheritanceType.JOINED)
@DiscriminatorColumn(name="CONTENT_TYPE", discriminatorType=javax.persistence.DiscriminatorType.INTEGER)
@DiscriminatorValue("4")
In son class here is the annotation and query:
@Entity
@Table(name = "ISBN_BOOK")
@DiscriminatorValue("1000001")
@NamedQueries( {
@NamedQuery(name = "ISBN_BOOK.findViaISBN", query = "SELECT g FROM ISBNBook g WHERE g.ISBNnumber = :isbn")
})
When I do the query, the result is:
Internal Exception: org.apache.derby.client.am.SqlException: Comparisons between 'INTEGER' and 'CHAR' are not supported.Error Code: -1
Call:SELECT t0.CONTENT_ID, t0.CONTENT_TYPE, t0.OBTAIN_DATE, t0.SEARCH_TIMES, t0.LAST_SEARCH_DATE, t1.CONTENT_ID, t1.BOOK_NAME, t1.AUTHOR, t1.ISBN_NUMBER, t1.CURRENT_LOCATION FROM CONTENT_MEDIA t0, ISBN_BOOK t1 WHERE ((t1.ISBN_NUMBER = CAST (? AS VARCHAR(32672) )) AND ((t1.CONTENT_ID = t0.CONTENT_ID) AND (t0.CONTENT_TYPE = '1000001')))
bind => [AAA]
The problem is: t0.CONTENT_TYPE = '1000001'. I have set the column to Integer, why the JPA use the char?
Can anyone solve the problem for me?

