|
From: <gca...@us...> - 2013-03-12 09:14:07
|
Revision: 4202
http://openutils.svn.sourceforge.net/openutils/?rev=4202&view=rev
Author: gcatania
Date: 2013-03-12 09:13:58 +0000 (Tue, 12 Mar 2013)
Log Message:
-----------
Merged revisions 4201 via svnmerge from
https://openutils.svn.sourceforge.net/svnroot/openutils/trunk/openutils-bshd5
........
r4201 | gcatania | 2013-03-12 10:06:55 +0100 (mar, 12 mar 2013) | 1 line
BSHD-20 make identifier restrictions alternative to examples and filter metadata
........
Revision Links:
--------------
http://openutils.svn.sourceforge.net/openutils/?rev=4201&view=rev
Modified Paths:
--------------
branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/ExampleTree.java
branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/ExampleTreeUtils.java
branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/FilterMetadataSupport.java
Property Changed:
----------------
branches/openutils-bshd5-backport/
branches/openutils-bshd5-backport/src/
Property changes on: branches/openutils-bshd5-backport
___________________________________________________________________
Modified: svnmerge-integrated
- /trunk/openutils-bshd5:1-4040,4042-4056,4058-4092,4192,4195
+ /trunk/openutils-bshd5:1-4040,4042-4056,4058-4092,4192,4195,4201
Modified: svn:mergeinfo
- /trunk/openutils-bshd5:4045-4047*,4057,4059,4069-4070*,4073*,4075-4078*,4080*,4082*,4084-4085*,4087*,4089*,4091-4092*,4192*,4195*
+ /trunk/openutils-bshd5:4045-4047*,4057,4059,4069-4070*,4073*,4075-4078*,4080*,4082*,4084-4085*,4087*,4089*,4091-4092*,4192*,4195*,4201*
Property changes on: branches/openutils-bshd5-backport/src
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/openutils-bshd5/src:4045-4047,4057,4069-4070,4073,4075-4078,4080,4082,4084-4085,4087,4089,4091-4092,4192,4195
+ /trunk/openutils-bshd5/src:4045-4047,4057,4069-4070,4073,4075-4078,4080,4082,4084-4085,4087,4089,4091-4092,4192,4195,4201
Modified: branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/ExampleTree.java
===================================================================
--- branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/ExampleTree.java 2013-03-12 09:06:55 UTC (rev 4201)
+++ branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/ExampleTree.java 2013-03-12 09:13:58 UTC (rev 4202)
@@ -255,6 +255,18 @@
private void createSubExamples(Criteria crit, Object entity, String[] walkedProperties)
{
+ ClassMetadata classMetadata = ExampleTreeUtils.getClassMetadata(entity, sessionFactory);
+ boolean isIdSet = ExampleTreeUtils.addIdentifierRestriction(
+ crit,
+ entity,
+ classMetadata,
+ sessionFactory.getCurrentSession()); // BSHD-11
+ if (isIdSet)
+ {
+ // BSHD-20 if the identifier is set on a property, do not impose further conditions
+ return;
+ }
+
String associationPath = ExampleTreeUtils.getPath(walkedProperties);
crit.add(example(entity, associationPath));
for (Criterion c : getAdditionalConditions(associationPath))
@@ -262,8 +274,6 @@
crit.add(c);
}
- ClassMetadata classMetadata = ExampleTreeUtils.getClassMetadata(entity, sessionFactory);
- ExampleTreeUtils.addIdentifierRestriction(crit, entity, classMetadata, sessionFactory.getCurrentSession()); // BSHD-11
Type[] types = classMetadata.getPropertyTypes();
String[] names = classMetadata.getPropertyNames();
for (int i = 0; i < types.length; i++)
Modified: branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/ExampleTreeUtils.java
===================================================================
--- branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/ExampleTreeUtils.java 2013-03-12 09:06:55 UTC (rev 4201)
+++ branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/ExampleTreeUtils.java 2013-03-12 09:13:58 UTC (rev 4202)
@@ -178,9 +178,11 @@
* @param entity the entity to use as example
* @param classMetadata the class metadata to use
* @param ses the current session
- * @see BSHD-11
+ * @return true if the identifier restriction has been added, false otherwise
+ * @see BSHD-11, BSHD-20
*/
- public static void addIdentifierRestriction(Criteria crit, Object entity, ClassMetadata classMetadata, Session ses)
+ public static boolean addIdentifierRestriction(Criteria crit, Object entity, ClassMetadata classMetadata,
+ Session ses)
{
String identifierName = classMetadata.getIdentifierPropertyName();
if (identifierName != null)
@@ -199,8 +201,10 @@
if (idValue != null) // TODO should we use property selectors instead?
{
crit.add(Restrictions.idEq(idValue));
+ return true;
}
}
+ return false;
}
}
Modified: branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/FilterMetadataSupport.java
===================================================================
--- branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/FilterMetadataSupport.java 2013-03-12 09:06:55 UTC (rev 4201)
+++ branches/openutils-bshd5-backport/src/main/java/it/openutils/hibernate/example/FilterMetadataSupport.java 2013-03-12 09:13:58 UTC (rev 4202)
@@ -112,12 +112,22 @@
private void createSubExamples(Criteria crit, Object entity, String[] walkedProperties)
{
+ ClassMetadata classMetadata = ExampleTreeUtils.getClassMetadata(entity, sessionFactory);
+ boolean isIdSet = ExampleTreeUtils.addIdentifierRestriction(
+ crit,
+ entity,
+ classMetadata,
+ sessionFactory.getCurrentSession()); // BSHD-11
+ if (isIdSet)
+ {
+ // BSHD-20 if the identifier is set on a property, do not impose further conditions
+ return;
+ }
+
String path = ExampleTreeUtils.getPath(walkedProperties);
Map<String, FilterMetadata> currFilterMetadata = getFilterMetadata(path);
crit.add(example(entity, currFilterMetadata.keySet()));
- ClassMetadata classMetadata = ExampleTreeUtils.getClassMetadata(entity, sessionFactory);
- ExampleTreeUtils.addIdentifierRestriction(crit, entity, classMetadata, sessionFactory.getCurrentSession()); // BSHD-11
Type[] types = classMetadata.getPropertyTypes();
String[] names = classMetadata.getPropertyNames();
for (int i = 0; i < types.length; i++)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|