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?

[1309 byte] By [purplecaesara] at [2007-11-27 8:07:33]
# 1

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]

he 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?

I think now it is more readable.

(use code tags pls)

Gantua at 2007-7-12 19:50:17 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...