<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<base href="https://hibernate.atlassian.net">
<title>Message Title</title>
</head>
<body class="jira" style="color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 1.429">
<table id="background-table" cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0; background-color: #f5f5f5; border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0" bgcolor="#f5f5f5">
<!-- header here -->
<tbody>
<tr>
<td id="header-pattern-container" style="padding: 0; border-collapse: collapse; padding: 10px 20px">
<table id="header-pattern" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0">
<tbody>
<tr>
<td id="header-avatar-image-container" valign="top" style="padding: 0; border-collapse: collapse; vertical-align: top; width: 32px; padding-right: 8px" width="32"> <img id="header-avatar-image" class="image_fix" src="cid:jira-generated-image-avatar-79f51fb6-cde3-4f0b-85c8-686c464eb18d" height="32" width="32" border="0" style="border-radius: 3px; vertical-align: top"> </td>
<td id="header-text-container" valign="middle" style="padding: 0; border-collapse: collapse; vertical-align: middle; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 1px"> <a class="user-hover" rel="sagnik" id="email_sagnik" href="https://hibernate.atlassian.net/secure/ViewProfile.jspa?name=sagnik" style="color:#6c797f;; color: #3b73af; text-decoration: none">sagnik sarkar</a> <strong>updated</strong> an issue </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td id="email-content-container" style="padding: 0; border-collapse: collapse; padding: 0 20px">
<table id="email-content-table" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0; border-spacing: 0; border-collapse: separate">
<tbody>
<tr>
<!-- there needs to be content in the cell for it to render in some clients -->
<td class="email-content-rounded-top mobile-expand" style="padding: 0; border-collapse: collapse; color: #ffffff; padding: 0 15px 0 16px; height: 15px; background-color: #ffffff; border-left: 1px solid #cccccc; border-top: 1px solid #cccccc; border-right: 1px solid #cccccc; border-bottom: 0; border-top-right-radius: 5px; border-top-left-radius: 5px; height: 10px; line-height: 10px; padding: 0 15px 0 16px; mso-line-height-rule: exactly" height="10" bgcolor="#ffffff"> </td>
</tr>
<tr>
<td class="email-content-main mobile-expand " style="padding: 0; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff" bgcolor="#ffffff">
<table class="page-title-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0">
<tbody>
<tr>
<td class="page-title-pattern-first-line " style="padding: 0; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; padding-top: 10px"> <a href="https://hibernate.atlassian.net/browse/HHH" style="color: #3b73af; text-decoration: none">Hibernate ORM</a> / <a href="https://hibernate.atlassian.net/browse/HHH-11229" style="color: #3b73af; text-decoration: none"><img src="cid:jira-generated-image-avatar-c4ef4cce-5d83-4807-9cdb-ce01e1c50159" height="16" width="16" border="0" align="absmiddle" alt="Bug" style="vertical-align: text-bottom"></a> <a href="https://hibernate.atlassian.net/browse/HHH-11229" style="color: #3b73af; text-decoration: none">HHH-11229</a> </td>
</tr>
<tr>
<td style="vertical-align: top;; padding: 0; border-collapse: collapse; padding-right: 5px; font-size: 20px; line-height: 30px; mso-line-height-rule: exactly" class="page-title-pattern-header-container"> <span class="page-title-pattern-header" style="font-family: Arial, sans-serif; padding: 0; font-size: 20px; line-height: 30px; mso-text-raise: 2px; mso-line-height-rule: exactly; vertical-align: middle"> <a href="https://hibernate.atlassian.net/browse/HHH-11229" style="color: #3b73af; text-decoration: none">Getting nullpointer exception while executing query</a> </span> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td class="email-content-main mobile-expand wrapper-special-margin" style="padding: 0; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff; padding-top: 10px; padding-bottom: 5px" bgcolor="#ffffff">
<table class="keyvalue-table" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0">
<tbody>
<tr>
<th style="color: #707070; font: normal 14px/20px Arial, sans-serif; text-align: left; vertical-align: top; padding: 2px 0">Change By:</th>
<td style="padding: 0; border-collapse: collapse; font: normal 14px/20px Arial, sans-serif; padding: 2px 0 2px 5px; vertical-align: top"> <a class="user-hover" rel="sagnik" id="email_sagnik" href="https://hibernate.atlassian.net/secure/ViewProfile.jspa?name=sagnik" style="color:#6c797f;; color: #3b73af; text-decoration: none">sagnik sarkar</a> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td class="email-content-main mobile-expand issue-description-container" style="padding: 0; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff; padding-top: 5px; padding-bottom: 10px" bgcolor="#ffffff">
<table class="text-paragraph-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 2px">
<tbody>
<tr>
<td class="text-paragraph-pattern-container mobile-resize-text " style="padding: 0; border-collapse: collapse; padding: 0 0 10px"> <span class="diffcontext">Hi,<br><br>I'm trying to upgrade my application from OpenJPA implementation 1.0.1 which was using JPA 1.0 to Hibernate 5.1.2<br><br>I'm getting nullpointer exception when trying to to call geResultList on a Entity class.<br><br>My Sample classes are below: (I've changed the class names as I can not share my original source code. But the mapping are same.)<br><br><br>1) Class Charger (Representing a sort of mobile charger that has 2 Pin)<br><br>@Entity<br>@Table(name = "Charger")<br>public class Charger extends ChargerEntityAbstract implements Serializable {<br> <br> @OneToMany(mappedBy="</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;">Charger</span> <span class="diffaddedchars" style="background-color:#ddfade;">charger</span> <span class="diffcontext">",targetEntity=PinEntityExt2.class,<br> fetch=FetchType.EAGER)<br> @Fetch(value = FetchMode.SUBSELECT)<br> public List<PinEntityExt2> pinEntityExtList;<br> <br> public List<PinEntityExt2> getPinEntityExtList() {<br> return pinEntityExtList;<br> }<br><br> public void setPinEntityExtList(List<PinEntityExt2> pinEntityExtList) {<br> this.pinEntityExtList = pinEntityExtList;<br> }<br> <br>}<br><br><br>2) <br><br>@MappedSuperclass<br>public class ChargerEntityAbstract implements Serializable {<br><br> private static final long serialVersionUID = 1L;<br><br> @Id<br> @Column(name="ID")<br> private Long Id;<br><br> @Column(name="CHARGER_ID", nullable = true)<br> private String chargerId;<br> <br> // *** Constructor ****<br> public ChargerEntityAbstract() {<br> }<br><br> // *** Getter and Setters ***<br> public Long getId() {<br> return this.Id;<br> }<br> public void setId(Long Id) {<br> this.Id = Id;<br> }<br><br><br> public String getChargerId() {<br> return chargerId;<br> }<br><br> public void setChargerId(String chargerId) {<br> this.chargerId = chargerId;<br> }<br><br>}<br><br>3) every charger has 2 pins so I've declared a bi-directional one to many mapping between Charger and pin.<br><br><br>@Entity<br>@Table(name = "PIN")<br>public class PinEntityExt2 extends PinEntityAbstract implements Serializable{<br><br> @Transient<br> private static final long serialVersionUID = -1L;<br> <br> @ManyToOne(optional=false)<br> @NotFound(action = NotFoundAction.IGNORE)<br> @JoinColumn(name="CHARGER_ID", referencedColumnName="CHARGER_ID", insertable= false, updatable = false)<br> private Charger charger;<br> <br> public Charger getCharger() {<br> return this.charger;<br> }<br><br> public void setCharger(Charger charger) {<br> this.charger = charger;<br> }<br> <br>}<br><br><br>4) PIN Entity has 2 properties. CHARGER_ID and PIN_NUMBER. this 2 field defines one record in the PIN table uniquely. So I've declared a IDclass (ChargerPin) for representing the composite key<br><br>@MappedSuperclass<br>@IdClass(ChargerPin.class)<br>public class PinEntityAbstract implements Serializable{<br> <br> @Transient<br> private static final long serialVersionUID = 1L;<br> <br> @Id<br> @Column(name="CHARGER_ID", nullable = true)<br> private String chargerId;<br> <br> @Id<br> @Column(name="PIN_NUMBER", nullable = true)<br> private Long pinNumber;<br> <br> public String getChargerId() {<br> return chargerId;<br> }<br><br> public void setChargerId(String chargerId) {<br> this.chargerId = chargerId;<br> }<br><br> public Long getPinNumber() {<br> return pinNumber;<br> }<br><br> public void setPinNumber(Long pinNumber) {<br> this.pinNumber = pinNumber;<br> }<br><br> <br>}<br><br><br><br>public class ChargerPin implements java.io.Serializable{<br><br> @Transient<br> private static final long serialVersionUID = 1L;<br><br> private String chargerId;<br> <br> private Long pinNumber;<br><br> // **** Constructor *****<br> public ChargerPin() {<br> }<br> <br> public ChargerPin(String chargerId, Long pinNumber) {<br> this.chargerId = chargerId;<br> this.pinNumber = pinNumber;<br> }<br><br> public String getChargerId() {<br> return chargerId;<br> }<br><br> public void setChargerId(String chargerId) {<br> this.chargerId = chargerId;<br> }<br><br> public Long getPinNumber() {<br> return pinNumber;<br> }<br><br> public void setPinNumber(Long pinNumber) {<br> this.pinNumber = pinNumber;<br> }<br> <br><br> <br> @Override<br> public int hashCode() {<br> <br> final int prime = 31;<br> int result = 1;<br> int chargerId = chargerId != null ?(Integer.parseInt(chargerId)):0;<br> int pinNumber = pinNumber!=null?(pinNumber).intValue():0;<br> result = prime * result + chargerId;<br> result = prime * result + pinNumber;<br> return result;<br> <br> }<br><br> @Override<br> public boolean equals(Object obj) {<br> <br> if (this == obj)<br> return true;<br> if (obj == null)<br> return false;<br> if (!(obj instanceof ChargerPin))<br> return false;<br> ChargerPin other = (ChargerPin) obj;<br> if (chargerId == null) {<br> if (other.chargerId != null)<br> return false;<br> } else if (!chargerId.equals(other.chargerId))<br> return false;<br> <br> if (pinNumber == null) {<br> if (other.pinNumber != null)<br> return false;<br> } else if (pinNumber != other.pinNumber)<br> return false;<br> <br> return true;<br> }<br> <br>}<br><br><br>5) Now while I'm invoking the below query I'm getting a nullPointer exception with Empty satck trace. <br><br>List<Charger> ChargerList = null;<br>Query query = null;<br>String queryString = "SELECT ce FROM Charger ce";<br>try {<br> em = getChargerEntityManager();<br> query = em.createQuery(queryString);<br> ChargerList = query.getResultList();<br><br>} catch (IllegalStateException e) {<br> log.error(e);<br>} catch (IllegalArgumentException e) {<br> log.error(e);<br>} catch (Exception e) {<br> log.error(e); <br>} finally{<br> closeEntityManager(em);<br>}<br><br><br>Can you please help me here. IS there anything wrong with the COMPOSITE Key implementation. Earlier I was trying with Hibernate 5.1.1. version and then the code was throwing error as "Error accessing field by reflection for persistent property". Then I changed the code base to use Hibernate version 5.1.2 and then without change of source code the exception got changed into Nullpointer exception.</span> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td class="email-content-main mobile-expand " style="padding: 0; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff" bgcolor="#ffffff"> <script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"description": "View Issue",
"potentialAction": {
"@type": "ViewAction",
"target": "https://hibernate.atlassian.net/browse/HHH-11229?inbox=true&",
"name": "View Issue"
},
"publisher": {
"@type": "Organization",
"name": "Atlassian",
"url": "https://www.atlassian.com"
}
}
</script>
<table id="actions-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 1px">
<tbody>
<tr>
<td id="actions-pattern-container" valign="middle" style="padding: 0; border-collapse: collapse; padding: 10px 0 10px 24px; vertical-align: middle; padding-left: 0">
<table align="left" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0">
<tbody>
<tr>
<td class="actions-pattern-action-icon-container" style="padding: 0; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 0; vertical-align: middle"> <a href="https://hibernate.atlassian.net/browse/HHH-11229#add-comment" target="_blank" title="Add Comment" style="color: #3b73af; text-decoration: none"> <img class="actions-pattern-action-icon-image" src="cid:jira-generated-image-static-comment-icon-93a6ca93-9a09-40ee-a9a4-29645073130a" alt="Add Comment" title="Add Comment" height="16" width="16" border="0" style="vertical-align: middle"> </a> </td>
<td class="actions-pattern-action-text-container" style="padding: 0; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 4px; padding-left: 5px"> <a href="https://hibernate.atlassian.net/browse/HHH-11229#add-comment" target="_blank" title="Add Comment" style="color: #3b73af; text-decoration: none">Add Comment</a> </td>
</tr>
</tbody>
</table> </td>
</tr>
</tbody>
</table> </td>
</tr>
<!-- there needs to be content in the cell for it to render in some clients -->
<tr>
<td class="email-content-rounded-bottom mobile-expand" style="padding: 0; border-collapse: collapse; color: #ffffff; padding: 0 15px 0 16px; height: 5px; line-height: 5px; background-color: #ffffff; border-top: 0; border-left: 1px solid #cccccc; border-bottom: 1px solid #cccccc; border-right: 1px solid #cccccc; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; mso-line-height-rule: exactly" height="5" bgcolor="#ffffff"> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td id="footer-pattern" style="padding: 0; border-collapse: collapse; padding: 12px 20px">
<table id="footer-pattern-container" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0">
<tbody>
<tr>
<td id="footer-pattern-text" class="mobile-resize-text" width="100%" style="padding: 0; border-collapse: collapse; color: #999999; font-size: 12px; line-height: 18px; font-family: Arial, sans-serif; mso-line-height-rule: exactly; mso-text-raise: 2px"> This message was sent by Atlassian JIRA <span id="footer-build-information">(v1000.499.4#100018-<span title="b6a952eafb8b7fc84197a7e35b1845752759a73a" data-commit-id="b6a952eafb8b7fc84197a7e35b1845752759a73a}">sha1:b6a952e</span>)</span> </td>
<td id="footer-pattern-logo-desktop-container" valign="top" style="padding: 0; border-collapse: collapse; padding-left: 20px; vertical-align: top">
<table style="border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0">
<tbody>
<tr>
<td id="footer-pattern-logo-desktop-padding" style="padding: 0; border-collapse: collapse; padding-top: 3px"> <img id="footer-pattern-logo-desktop" src="cid:jira-generated-image-static-footer-desktop-logo-4edf98bb-80db-406e-8d71-ac5db16ad44a" alt="Atlassian logo" title="Atlassian logo" width="169" height="36" class="image_fix"> </td>
</tr>
</tbody>
</table> </td>
</tr>
</tbody>
</table> </td>
</tr>
</tbody>
</table>
</body>
</html>