| Summary: | field access cause NullPointerException | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | nossie531 |
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | tom.ware |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows Vista | ||
| Whiteboard: | |||
I suspect this is related to the fact that you are expecting autoboxing to work on the followings statement:
return this.value != 1?true:false;
You expect "1" to be autoboxed to an Integer. It is possible that our bytecode weaving will defeat that assumption.
Does return this.value != Integer.valueOf(1)?true:false; solve the problem?
Closing as WONTFIX.
Oh!! work fine! Thank you!! And I'm sorry I post wrong!! The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
Build Identifier: Sorry I'm not good at English... But I noticed very strange behavior at EclipseLink. If compare EntityBean field(null) to null, cause NullPointerException. (if compare EntityBean field(null) to other, cause no exception.) And strangely this NullPointerException's stackTrace is null! Uhh... because of bytecode conversion or dynamic weaving??? My enviroments are follows; EclipseLink: nightly 2.2.0(2010/8/19)r8063 Server: Glassfish v3.0.1 JDBC connector:mysql-connector-java-5.1.3-rc-bin.jar IDE: Eclipse Helios Reproducible: Always Steps to Reproduce: 1. create database "test" and run sql. CREATE TABLE test ( id INTEGER NOT NULL AUTO_INCREMENT, value INTEGER DEFAULT NULL, PRIMARY KEY(id) ) ENGINE = INNODB; INSERT INTO test ( id, value ) VALUES ( 1, NULL ); 2. TestEntityBean.java package jpa; import java.io.Serializable; import javax.persistence.*; @Entity @Table(schema="test", name="test") public class TestEntityBean implements Serializable { private static final long serialVersionUID = 7100714529417828468L; @Id @Column(name = "id", nullable = false) private int id; @Column(name="value") private Integer value; public TestEntityBean() { super(); } public boolean test() { // OK. // return this.value != null?true:false; // NG. NullPointerException !! return this.value != 1?true:false; } } 3. TestManagedBean.java package jsf; import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import jpa.TestEntityBean; @ManagedBean(name="test") @RequestScoped public class TestManagedBean { @PersistenceContext(unitName="test") private EntityManager em; public void test() { TestEntityBean test = em.find(TestEntityBean.class, 1); test.test(); } } 4. test.xhtml <?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:my="http://www.test.com/tag.taglib.xml"> <head> <title>test</title> </head> <body> <f:view> <h:form> <h:commandButton action="#{test.test}"/> </h:form> </f:view> </body> </html> 5.persistence.xml <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="test" transaction-type="JTA"> <provider> org.eclipse.persistence.jpa.PersistenceProvider </provider> <jta-data-source>jdbc/MySql</jta-data-source> <properties> <property name="eclipselink.logging.level" value="Fine" /> </properties> </persistence-unit> </persistence>