<!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: #333; 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: 0pt; mso-table-rspace: 0pt; background-color: #f5f5f5; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<!-- header here -->
<tr>
<td id="header-pattern-container" style="padding: 0px; border-collapse: collapse; padding: 10px 20px">
<table id="header-pattern" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tr>
<td id="header-avatar-image-container" valign="top" style="padding: 0px; border-collapse: collapse; vertical-align: top; width: 32px; padding-right: 8px"> <img id="header-avatar-image" class="image_fix" src="https://secure.gravatar.com/avatar/f32e2c7157c84dddcb339d0714bb6025?d=mm&s=48" height="32" width="32" border="0" style="border-radius: 3px; vertical-align: top" />
</td>
<td id="header-text-container" valign="middle" style="padding: 0px; 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="wernerg" id="email_wernerg" href="https://hibernate.atlassian.net/secure/ViewProfile.jspa?name=wernerg" style="color:#6c797f;; color: #3b73af; text-decoration: none">Werner Gindhart</a> <strong>created</strong> an issue
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td id="email-content-container" style="padding: 0px; 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: 0pt; mso-table-rspace: 0pt; border-spacing: 0; border-collapse: separate">
<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: 0px; border-collapse: collapse; color: #fff; padding: 0 15px 0 16px; height: 15px; background-color: #fff; border-left: 1px solid #ccc; border-top: 1px solid #ccc; border-right: 1px solid #ccc; 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">
</td>
</tr>
<tr>
<td class="email-content-main mobile-expand " style="padding: 0px; border-collapse: collapse; border-left: 1px solid #ccc; border-right: 1px solid #ccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #fff">
<table class="page-title-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tr>
<td class="page-title-pattern-first-line " style="padding: 0px; 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-8808" style="color: #3b73af; text-decoration: none"><img src="https://hibernate.atlassian.net/images/icons/issuetypes/newfeature.png" height="16" width="16" border="0" align="absmiddle" alt="New Feature" style="vertical-align: text-bottom" /></a> <a href="https://hibernate.atlassian.net/browse/HHH-8808" style="color: #3b73af; text-decoration: none">HHH-8808</a>
</td>
</tr>
<tr>
<td style="vertical-align: top;; padding: 0px; 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-8808" style="color: #3b73af; text-decoration: none">Navigable historization of entities and associations</a> </span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="email-content-main mobile-expand wrapper-special-margin" style="padding: 0px; border-collapse: collapse; border-left: 1px solid #ccc; border-right: 1px solid #ccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #fff; padding-top: 10px; padding-bottom: 5px">
<table class="keyvalue-table" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tr>
<th style="color: #707070; font: normal 14px/20px Arial, sans-serif; text-align: left; vertical-align: top; padding: 2px 0">
Issue Type:
</th>
<td class="has-icon" style="padding: 0px; border-collapse: collapse; font: normal 14px/20px Arial, sans-serif; padding: 2px 0 2px 5px; vertical-align: top"> <img src="https://hibernate.atlassian.net/images/icons/issuetypes/newfeature.png" height="16" width="16" border="0" align="absmiddle" alt="New Feature" style="vertical-align: text-bottom" /> New Feature
</td>
</tr>
<tr>
<th style="color: #707070; font: normal 14px/20px Arial, sans-serif; text-align: left; vertical-align: top; padding: 2px 0">
Affects Versions:
</th>
<td style="padding: 0px; border-collapse: collapse; font: normal 14px/20px Arial, sans-serif; padding: 2px 0 2px 5px; vertical-align: top">
4.3.0.CR2, 5.0.0
</td>
</tr>
<tr>
<th style="color: #707070; font: normal 14px/20px Arial, sans-serif; text-align: left; vertical-align: top; padding: 2px 0">
Assignee:
</th>
<td style="padding: 0px; border-collapse: collapse; font: normal 14px/20px Arial, sans-serif; padding: 2px 0 2px 5px; vertical-align: top">
Unassigned
</td>
</tr>
<tr>
<th style="color: #707070; font: normal 14px/20px Arial, sans-serif; text-align: left; vertical-align: top; padding: 2px 0">
Components:
</th>
<td style="padding: 0px; border-collapse: collapse; font: normal 14px/20px Arial, sans-serif; padding: 2px 0 2px 5px; vertical-align: top">
annotations, core, envers, metamodel
</td>
</tr>
<tr>
<th style="color: #707070; font: normal 14px/20px Arial, sans-serif; text-align: left; vertical-align: top; padding: 2px 0">
Created:
</th>
<td style="padding: 0px; border-collapse: collapse; font: normal 14px/20px Arial, sans-serif; padding: 2px 0 2px 5px; vertical-align: top">
19/Dec/13 4:44 AM
</td>
</tr>
<tr>
<th style="color: #707070; font: normal 14px/20px Arial, sans-serif; text-align: left; vertical-align: top; padding: 2px 0">
Labels:
</th>
<td style="padding: 0px; border-collapse: collapse; font: normal 14px/20px Arial, sans-serif; padding: 2px 0 2px 5px; vertical-align: top">
historization
</td>
</tr>
<tr>
<th style="color: #707070; font: normal 14px/20px Arial, sans-serif; text-align: left; vertical-align: top; padding: 2px 0">
Priority:
</th>
<td class="has-icon" style="padding: 0px; border-collapse: collapse; font: normal 14px/20px Arial, sans-serif; padding: 2px 0 2px 5px; vertical-align: top"> <img src="https://hibernate.atlassian.net/images/icons/priorities/major.png" height="16" width="16" border="0" align="absmiddle" alt="Major" style="vertical-align: text-bottom" /> Major
</td>
</tr>
<tr>
<th style="color: #707070; font: normal 14px/20px Arial, sans-serif; text-align: left; vertical-align: top; padding: 2px 0">
Reporter:
</th>
<td style="padding: 0px; border-collapse: collapse; font: normal 14px/20px Arial, sans-serif; padding: 2px 0 2px 5px; vertical-align: top"> <a class="user-hover" rel="wernerg" id="email_wernerg" href="https://hibernate.atlassian.net/secure/ViewProfile.jspa?name=wernerg" style="color:#6c797f;; color: #3b73af; text-decoration: none">Werner Gindhart</a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="email-content-main mobile-expand issue-description-container" style="padding: 0px; border-collapse: collapse; border-left: 1px solid #ccc; border-right: 1px solid #ccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #fff; padding-top: 5px; padding-bottom: 10px">
<table class="text-paragraph-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 2px">
<tr>
<td class="text-paragraph-pattern-container mobile-resize-text " style="padding: 0px; border-collapse: collapse; padding: 0 0 10px 0">
<p style="margin-top:0;margin-bottom:10px;; margin: 10px 0 0 0"><p><b>Use case:</b><br /> <br>A company has associated some stuff like houses, persons, buildings. <br /> The objects and associations change over time as well as in quality (e.g. building is rented, owned ...).</p>
<p style="margin-top:0;margin-bottom:10px;; margin: 10px 0 0 0">Now the company wants to build reports of the company state for certain different points of time in past,<br /> without having to adapt the report definition to recognize the point of time definition or specific historization tools like Hibernate Envers.</p>
<p style="margin-top:0;margin-bottom:10px;; margin: 10px 0 0 0"><p><b>Problem description:</b><br /> There is a currently effective set of objects which can be easily queried by hibernate (JPQL) selects.</p>
<p style="margin-top:0;margin-bottom:10px;; margin: 10px 0 0 0">If some changes are made, this can be documented via Hibernate Envers, storing old object versions in separate tables.<br /> But if you want to retrieve a complete set of objects valid for a certain due date (or timestamp value), <br /> you have to do some special Envers queries which causes many extra coding.<br /> If you want to do some reporting using JasperReports or BIRT navigating via JPQL you can not use these tools<br /> without writing new report definitions (if possible with envers at all).</p>
<p style="margin-top:0;margin-bottom:10px;; margin: 10px 0 0 0"><p><b>Proposed solution principle:</b><br /> <ol><br /> <li>In every session must be defined a query effectivity item (date or timestamp) which defines the point of interest in time for which all queries within this session will be processed.<br /> <br>If not set, the current time is used as point of interest in time.</li><br /> <li>Every entity relevant for historization must define an effectivity time span, which will define the set of of entity objects valid for all queries.</li><br /> <li>The different versions of the same object build up an logical domain.<br /> <br>If an query effectivity item is set in session, then at most ONE object of every object domain will be found by a any query.<br><br /> </li><br /> </ol></p>
<p style="margin-top:0;margin-bottom:10px;; margin: 10px 0 0 0"><p><b>Proposed hibernate solution (theory):</b><br /> <br><b>All following definitions apply only to entities relevant for historization.</b><br>Entities not relevant for historization are handled as before.<br /> <ol><br /> <li>The session accepts an Calender value which defines the current point of interest in time for all subsequent queries. Lets call it "Session Effectivity Criteria".<br /> <br>For possibly influencing all formerly read objects, the object cache of the session must be cleared , when this value is set.<br /> <br>If not set, the current time is used as criteria.<br /> Of course, a flush operation may be neccessary, too.</li><br /> <li>Every entity must define two temporal attributes which define the effectivity time span for an object version.<br /> <br>Lets call them "Effectivity Start" and "Effectivity End"<br /> <br>When persisting an objects version there are three rules to be checked:<br /> <ol><br /> <li>"Effectivity Start" and "Effectivity End" must both not be null.<br>This is because it's easier and probably faster to search with only one "between" expression.</li><br /> <li>"Effectivity Start" must be less than "Effectivity End".</li><br /> <li>Within an object domain there must not be other object versions which overlap the same effectivity time span as the object to be persisted.</li><br /> </ol> <br /> </li><br /> <li>For identification of the objects different time dependent versions of the same object (object domain) the entity must defined an attribute which works as a link between the separate versions.<br /> Lets call it "Object Domain Id".<br>All different versions of an object have an "Object Domain Id" of the same value.</li><br /> <li>All association definitions like @ManyToOne, @OneToOne, @OneToMany targeting to an entity relevant for historization, do not implicitly relate to the objects id, but to the "Object Domain Id"</li><br /> <li>All select operations for an entity add an additional fragment to the where clause which limit the found objects to this condition :<br><i>"Effectivity Start" <b><=</b> "Session Effectivity Criteria" <b><</b> "Effectivity End".<br /> <br>This applies to all select operations except those which define load operations needing explicitely use of the object id (e.g. load for UPGRADE, PESSIMISTIC_READ etc.).<br /> </li><br /> </ol></p>
<p style="margin-top:0;margin-bottom:10px;; margin: 10px 0 0 0"><p><b>Proposed hibernate solution (practice):</b><br /> <ol><br /> <li>The interface "org.hibernate.Session" (and its derived classes) must be expanded by follwing methodes:<br /> <ul><br /> <li>setEffectivityCriteria(java.util.Calendar)<br>Set the "Session Effectivity Criteria",so that this point of time is used as effectivity criteria within further queries of the session.</li><br /> <li>resetEffectivityCriteria()<br>Reset the "Session Effectivity Criteria",so that the current time is used as effectivity criteria within further queries of the session.</li><br /> <li>List<java.util.Calendar>getEffectivityStarts(java.lang.Object entityObject, java.util.Calendar earliestStart, java.util.Calendar latestStart, int maxResults)<br /> <br>Returns an ordered by timestamp list of effectivity start points of time for a certain object (respectively the domain of this object).<br /> <br>The parameter "earliestStart" means that, if it exists, the effectivity start point of the object should returned, which has been valid at earliestStart. <br /> <br>That means the first returned effectivity start point can be less than the value of the "earliestStart" parameter.<br /> <br>This method can be used to determine which versions of an object exist.</li><br /> </ul><br /> <li>An Annotation "@EffectivtyDomainId" will be introduced which defines the "Object Domain Id"-Attribute of the entity.<br /> <br>May be this should automatically imply "nullable = false" and "updateable = false".</li><br /> <li>Two Annotations "@EffectivtyStart" and "@EffectivtyStart" will be introduced which define the "Effectivity Start" and "Effectivity End"-Attributes of the entity.<br /> <br>The annotated attribute must be annotated by @Temporal, too.<br /> <br>May be this should automatically imply "nullable = false".<br /> </li><br /> <li>Adaption of the classes "org.hibernate.hql.internal.antlr.HqlSqlBaseWalker" and "org.hibernate.hql.internal.ast.HqlSqlWalker" <br /> and may be others for application of the "Object Domain Id"-Attribute instead of the "Id"-Attribute for all applicable queries.<br /> Especially regarding joins between and to historizable entities<br></li><br /> </ol></p>
<p style="margin-top:0;margin-bottom:10px;; margin: 10px 0 0 0"><p><b>Possible cooperation with Envers:</b><br /> <br>If the value of an entity attribute changes without change of the effectivity span of the object, Envers could be used for tracking the changes (regarding what / who).<br /> <p><br /> If the value of an entity attribute changes from a certain point of time on (e.g. directly chronologically following), <br /> then the "old" version of the object will be changed in "Effectivity End" and a new copy of the object with new effectivity bounds will be created.<br /> <br>In this case Envers tracks the values too (for forensic purposes), but effectivty sensible reports will only read the main entities.</p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="email-content-main mobile-expand " style="padding: 0px; border-collapse: collapse; border-left: 1px solid #ccc; border-right: 1px solid #ccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #fff">
<table id="actions-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 1px">
<tr>
<td id="actions-pattern-container" valign="middle" style="padding: 0px; border-collapse: collapse; padding: 10px 0 10px 24px; vertical-align: middle; padding-left: 0">
<table align="left" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tr>
<td class="actions-pattern-action-icon-container" style="padding: 0px; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 0px; vertical-align: middle"> <a href="https://hibernate.atlassian.net/browse/HHH-8808#add-comment" target="_blank" title="Add Comment" style="color: #3b73af; text-decoration: none"> <img class="actions-pattern-action-icon-image" src="https://hibernate.atlassian.net/images/mail/comment-icon.png" 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: 0px; 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-8808#add-comment" target="_blank" title="Add Comment" style="color: #3b73af; text-decoration: none">Add Comment</a>
</td>
</tr>
</table>
</td>
</tr>
</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: 0px; border-collapse: collapse; color: #fff; padding: 0 15px 0 16px; height: 5px; line-height: 5px; background-color: #fff; border-top: 0; border-left: 1px solid #ccc; border-bottom: 1px solid #ccc; border-right: 1px solid #ccc; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; mso-line-height-rule: exactly">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td id="footer-pattern" style="padding: 0px; border-collapse: collapse; padding: 12px 20px">
<table id="footer-pattern-container" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tr>
<td id="footer-pattern-text" class="mobile-resize-text" width="100%" style="padding: 0px; border-collapse: collapse; color: #999; 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">(v6.2-OD-05-4#6207-<span title="cd2d72fc0cc1a6ce24fcef98c746fc7603bc8943" data-commit-id="cd2d72fc0cc1a6ce24fcef98c746fc7603bc8943}">sha1:cd2d72f</span>)</span>
</td>
<td id="footer-pattern-logo-desktop-container" valign="top" style="padding: 0px; border-collapse: collapse; padding-left: 20px; vertical-align: top">
<table style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tr>
<td id="footer-pattern-logo-desktop-padding" style="padding: 0px; border-collapse: collapse; padding-top: 3px"> <img id="footer-pattern-logo-desktop" src="https://hibernate.atlassian.net/images/mail/footer-desktop-logo.png" alt="Atlassian logo" title="Atlassian logo" width="169" height="36" class="image_fix" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>