<!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-020207de-834c-41e3-ace9-a15ea96b899d" 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="son" id="email_son" href="https://hibernate.atlassian.net/secure/ViewProfile.jspa?name=son" style="color:#6c797f;; color: #3b73af; text-decoration: none">Sönke reimer</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-11508" style="color: #3b73af; text-decoration: none"><img src="cid:jira-generated-image-avatar-a483945d-c6c1-4ccc-a9b9-6b2bb49e95ae" height="16" width="16" border="0" align="absmiddle" alt="Bug" style="vertical-align: text-bottom"></a> <a href="https://hibernate.atlassian.net/browse/HHH-11508" style="color: #3b73af; text-decoration: none">HHH-11508</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-11508" style="color: #3b73af; text-decoration: none">SingleIdMapper does not extract values from Id-Class </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="son" id="email_son" href="https://hibernate.atlassian.net/secure/ViewProfile.jspa?name=son" style="color:#6c797f;; color: #3b73af; text-decoration: none">Sönke reimer</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">Hello,<br><br>I'm new to your issue tracking system and at first<br>I would like to thank you for your years of working on hibernate.<br><br>I have JPA-Entities with composite primary keys ( and therefore composite foreign keys ).<br>They consist of (Id : String, ClientId : String) and the Id-Class is not mapped as embedded.<br>{code}<br>public interface CLId extends Serializable {<br> <br> /**<br> * The unique id of the entity<br> * <br> * @return the id<br> */<br> public String getId();<br> <br> /**<br> * The client id of the entity<br> * <br> * @return the client id<br> */<br> public String getClientId();<br><br>}<br>{code}<br>{code}<br>/**<br> * Gruppe entity id class.<br> * @see Gruppe<br> */<br>@SuppressWarnings("all")<br>public class _GruppeId implements CLId {<br><br> @Column(name = "ID")<br> private String Id;<br><br> @Column(name = "CLIENTID")<br> private String ClientId;<br> <br> public _GruppeId() {}<br> public _GruppeId(String aId, String aClientId) {<br> setId(aId);<br> setClientId(aClientId);<br> }<br> <br> public String getId() {<br> return Id;<br> }<br><br> public void setId(String aId) {<br> this.Id = aId;<br> }<br><br> public String getClientId() {<br><br> return ClientId;<br> }<br><br> public void setClientId(String aClientId) {<br> ClientId = aClientId;<br> }<br><br> public boolean equals(Object o) { <br> return ((o instanceof _GruppeId) && <br> getId().equals(((_GruppeId)o).getId()) &&<br> getClientId().equals(((_GruppeId) o).getClientId()));<br> }<br><br> public int hashCode() { <br> return Id.hashCode() + getClientId().hashCode(); <br> }<br><br> @Override<br> public String toString() {<br> <br> Class<?> clazz = getClass();<br> return clazz.getSimpleName() + "@Id=" + getId() + ",ClientId=" + getClientId();<br> }<br>}<br>{code}<br>{code}<br></span> <span class="diffaddedchars" style="background-color:#ddfade;">@MappedSuperclass<br>@Table(indexes={<br> @Index(columnList="LOCK_VERSION")<br>})<br>public class EntityImpl<br>{<br> <br></span> <span class="diffcontext">/**<br> *</span> <span class="diffaddedchars" style="background-color:#ddfade;"> Implementation for access to business methods<br> */<br> protected transient EntityBL ivEntityBL = null;<br><br> /**<br> * primary key of the entity<br> */<br> @Id<br> @Column(name = "ID")<br> private String Id;<br><br> /**<br> * lock version for optimistic locking<br> */<br> @Version<br> @Column(name = "LOCK_VERSION")<br> private int Lock_Version;<br><br><br> protected EntityImpl(int aParam)<br> {<br> super();<br> }<br><br> public void createEntityBL()<br> {<br> <br> }<br><br> <br> public <T extends Entity> void init(EntityInit<T> aInitializer) {<br><br> MonitoringProbe probe = Log4jMonitoringProbe.start(getClass().getName(), EntityImpl.class.getName() + ".init(EntityInitializer)");<br> try {<br> if (getEntityBL() != null) {<br> getEntityBL().init();<br> } <br> if (aInitializer != null) {<br> aInitializer.init((T)this);<br> }<br> } catch (RuntimeException e) {<br> probe.setFailed(e);<br> throw e;<br> } catch (Error e) {<br> probe.setFailed(e);<br> throw e;<br> } finally {<br> probe.stop(); <br> }<br> }<br> <br> @PreRemove<br> public void preRemove() {<br><br> MonitoringProbe probe = Log4jMonitoringProbe.start(getClass().getName(), EntityBL.class.getName() + ".preRemove()");<br> try {<br> if (getEntityBL() != null) {<br> getEntityBL().onRemove();<br> }<br> onRemoveImpl();<br> } catch (RuntimeException e) {<br> probe.setFailed(e);<br> throw e;<br> } catch (Error e) {<br> probe.setFailed(e);<br> throw e;<br> } finally {<br> probe.stop(); <br> }<br> } <br> <br> public void onRemoveImpl() { <br> }<br> <br> public EntityBL getEntityBL()<br> {<br> return ivEntityBL;<br> }<br><br> public String getId()<br> {<br> return Id;<br> }<br><br> public void setId(String aId)<br> {<br> Id = aId;<br> }<br><br> <br> public int getLock_Version()<br> {<br> return Lock_Version;<br> }<br><br> public void setLock_Version(int aLock_Version)<br> {<br> Lock_Version = aLock_Version;<br> }<br><br> <br> public void checkStaleness(EntityPK aEntityPK) throws OptimisticLockException<br> {<br> if (!this.getId().equals(((EntityPKImpl) aEntityPK).getId()))<br> {<br> throw new IllegalArgumentException("Id of Entity differs from given Id of EntityPK");<br> }<br><br> if (!(this.getLock_Version() == ((EntityPKImpl) aEntityPK).getLock_Version()))<br> {<br> throw new OptimisticLockException("Lock_Version of Entity differs from Lock_Version of EntityPK", null, this);<br> }<br> }<br><br> public AMPersistenceContext getPersistenceContext() {<br> return PersistenceContextHolder.getPersistenceContext();<br> }<br><br> /**<br> * The modification user for the current thread<br> * <br> * @return the uset string<br> */<br> protected String getModificationUser()<br> {<br> return (String) Logger.getVariable(ModificationInfo.USER);<br> }<br><br> /**<br> * The modification timestamp<br> * <br> * @return the modification timestamp <br> */<br> protected Timestamp getModificationTimestamp()<br> {<br> return ((AMEntityManager)getPersistenceContext().getEntityManager()).getModificationTimestamp(); <br> }<br> <br> /**<br> * Checks a string for not being empty with regard to <br> * Oracle, where empty strings are converted to null.<br> * <br> * @param aString the string<br> */<br> protected void checkStringForEmptyness(String aString) {<br> if ( aString != null && aString.length() == 0) {<br> throw new IllegalArgumentException("Persisted string is empty.\nValid String must be 'null' or not empty!"); <br> }<br> }<br> <br> /**<br> * Returns the implementation for a given entity reference.<br> * If the given object is a proxy, the target object of the proxy will be <br> * returned, otherwise the object itself.<br> * @param <T> the entity type<br> * @param entity the entity reference<br> * @return the entity implementation<br> */<br> public static <T> T getImpl(T entity) {<br> return EntityUtil.getImpl(entity);<br> }<br>{code}<br>{code}<br>public abstract class CLEntityImpl extends EntityImpl {<br><br> public CLEntityImpl(int aParam)<br> {<br> super(aParam);<br> }<br><br> /**<br> * Set the non null client id of the entity.<br> * <br> * @param aClientId the id of the client<br> */<br> public abstract void setClientId(String aClientId);<br> <br> /**<br> * Get the client id of the entity<br> * <br> * @return the client id<br> */<br> public abstract String getClientId(); <br>}<br>{code}<br>{code}<br>/**<br> *</span> <span class="diffcontext"> Gruppe entity instance implementation.<br> */<br>@Audited<br>@Entity(name="Gruppe")<br>@IdClass(_GruppeId.class)<br>@FilterDef(name="ClientIdFilter", parameters={ @ParamDef( name="ClientId", type="string" ) } )<br>@Filter(name="ClientIdFilter", condition="CLIENTID = :ClientId")<br>@Table(name="GRUPPE",<br> indexes = {<br> })<br>@Proxy(lazy=true, proxyClass=_GruppeProxy.class)<br>@SuppressWarnings("all")<br>public class _GruppeImpl extends CLEntityImpl implements _GruppeProxy {<br><br><br> /**<br> * client to which the entity belongs<br> */<br> @Column(name = "CLIENTID")<br> private String ClientId;<br><br> @Basic<br> @Column(name="NAME")<br> private String ivName;<br><br> public _GruppeImpl() {<br><br> this(0);<br> createEntityBL();<br> }<br><br> //only another constructor<br> protected _GruppeImpl(int aParam) {<br><br> super(aParam);<br><br> }<br><br><br><br> public EntityPK getPK () {<br><br> _GruppePKImpl gruppePKImpl = new _GruppePKImpl();<br> gruppePKImpl.setId(getId());<br> gruppePKImpl.setClientId(getClientId());<br> gruppePKImpl.setLock_Version(getLock_Version());<br> return gruppePKImpl;<br> }<br><br> @Override<br> public boolean equals(Object o) { <br> return ((o instanceof Gruppe) && <br> getPK().equals(((Gruppe)o).getPK()));<br> }<br> <br> @Override<br> public int hashCode() {<br><br> return getPK().hashCode();<br> }<br> <br> /**<br> * getter for Client.<br> */<br> public String getClientId() {<br><br> return ClientId;<br> }<br><br> /**<br> * setter for Client.<br> */<br> public void setClientId(String aClientId) {<br><br> ClientId = aClientId;<br> }<br> <br> @Override<br> public String getName() {<br> <br> return ivName;<br> }<br> <br> @Override<br> public void setName(String aName) {<br> <br> checkStringForEmptyness(aName);<br> ivName = aName;<br> }<br>{code}<br>When trying to audit a relation to another entity with envers, <br>Hibernate's BasicBinder class fails with a ClassCastException on trying to set Id-Class instance to ClientId/Id-values, when trying to persist to the audit table.<br><br>After spending a few hours of work, I found out, that in class <br>org.hibernate.envers.internal.entities.mapper.id.SingleIdMapper.mapToMapFromEntity(...)<br>{code}<br> @Override<br> public void mapToMapFromEntity(Map<String, Object> data, Object obj) {<br> if ( obj == null ) {<br> data.put( propertyData.getName(), null );<br> }<br> else {<br> if ( obj instanceof HibernateProxy ) {<br> final HibernateProxy hibernateProxy = (HibernateProxy) obj;<br> data.put( propertyData.getName(), hibernateProxy.getHibernateLazyInitializer().getIdentifier() );<br> }<br> else {<br> final Getter getter = ReflectionTools.getGetter( obj.getClass(), propertyData );<br> data.put( propertyData.getName(), getter.get( obj ) );<br> }<br> }<br> }<br>{code}<br>properties of the Id-Class are not extracted, when having a proxy.<br>This seems to be a bug, <br></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-11508?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-11508#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-fe611734-ad07-4dea-9726-eb2aa1ca9662" 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-11508#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.773.3#100032-<span title="fedc5ae5e5250397045227deb331a497ac569c04" data-commit-id="fedc5ae5e5250397045227deb331a497ac569c04}">sha1:fedc5ae</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-2e4ca89c-196e-45c7-ad22-6d3c7c549da2" 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>