Hi Warren,
What does the table for Book look like? How is the column for illustrations
defined?
What is the exception trace?
-Tom
Warren Tang wrote:
Hi everyone,
I've just began to learn EclipseLink. I've got into trouble on a sample
built with JPA and Derby. When calling entitymanager.persist and then
committing, an error is thrown:
Rollback Exception [cause = java.lang.ClassCastException:
java.lang.Boolean cannot be cast to java.lang.Short]
The problem seems to be the Boolean type. If I change it to Short the
error goes away. But cannot I use Boolean type? Isn't EclipseLink
supposed to do the conversion for me? Or is there some special syntax to
do it?
The entity class is as follows:
@Entity
@NamedQuery(name = "findAllBooks", query="select b from Book b")
public class Book {
@Id @GeneratedValue
private Long id;
@Column(nullable = false)
private String title;
private Float price;
@Column(length = 2000)
private String description;
private String isbn;
private Integer nbOfPage;
private Boolean illustrations;
//getters/setters omitted.
}
The sample is compiled against Java 1.6 and the dependencies defined in
pom.xml are as follows:
<dependencies>
<!-- JPA interface -->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.0</version>
</dependency>
<!-- Persistence provider -->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.0.0</version>
</dependency>
<!-- Derby JDBC driver -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.8.1.2</version>
</dependency>
<!-- Derby embedded jar -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.8.1.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
</dependencies>
--
Regards,
Warren Tang <http://blog.tangcs.com>
------------------------------------------------------------------------
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users