r2896 - in trunk: topia-it/src/test/java/org/nuiton/topia/it/legacy topia-persistence/src/main/java/org/nuiton/topia
Author: athimel Date: 2013-11-27 08:38:49 +0100 (Wed, 27 Nov 2013) New Revision: 2896 Url: http://nuiton.org/projects/topia/repository/revisions/2896 Log: refs #2923 Remove deprecated code from TopiaJpaSupport Modified: trunk/topia-it/src/test/java/org/nuiton/topia/it/legacy/TopiaJpaSupportTest.java trunk/topia-persistence/src/main/java/org/nuiton/topia/HibernateTopiaJpaSupport.java trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaJpaSupport.java Modified: trunk/topia-it/src/test/java/org/nuiton/topia/it/legacy/TopiaJpaSupportTest.java =================================================================== --- trunk/topia-it/src/test/java/org/nuiton/topia/it/legacy/TopiaJpaSupportTest.java 2013-11-26 17:19:25 UTC (rev 2895) +++ trunk/topia-it/src/test/java/org/nuiton/topia/it/legacy/TopiaJpaSupportTest.java 2013-11-27 07:38:49 UTC (rev 2896) @@ -40,7 +40,10 @@ import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.util.List; +import java.util.Map; +import com.google.common.collect.Maps; + /** * Tests the TopiaContext#find|findAll|findUnique methods * @@ -105,17 +108,24 @@ String query = "from " + Personne.class.getName() + " where " + Personne.PROPERTY_GENDER + "=:g"; - List females = jpaSupport.findAll(query, "g", Gender.FEMALE); + Map<String, Object> args = Maps.newHashMap(); + args.put("g", Gender.FEMALE); + List females = jpaSupport.findAll(query, args); Assert.assertEquals(2, females.size()); - List males = jpaSupport.findAll(query, "g", Gender.MALE); + args = Maps.newHashMap(); + args.put("g", Gender.MALE); + List males = jpaSupport.findAll(query, args); Assert.assertEquals(1, males.size()); - List all = jpaSupport.findAll("from " + Personne.class.getName()); + args = Maps.newHashMap(); + List all = jpaSupport.findAll("from " + Personne.class.getName(), args); Assert.assertEquals(3, all.size()); + args = Maps.newHashMap(); + args.put("pax", "nobody"); List none = jpaSupport.findAll("from " + Personne.class.getName() + - " where " + Personne.PROPERTY_NAME + "=:pax", "pax", "nobody"); + " where " + Personne.PROPERTY_NAME + "=:pax", args); Assert.assertEquals(0, none.size()); } @@ -126,14 +136,17 @@ String query = "from " + Personne.class.getName() + " where " + Personne.PROPERTY_GENDER + "=:g"; - List females = jpaSupport.find(query, 0, 100, "g", Gender.FEMALE); + + Map<String, Object> args = Maps.newHashMap(); + args.put("g", Gender.FEMALE); + List females = jpaSupport.find(query, 0, 100, args); Assert.assertEquals(2, females.size()); - females = jpaSupport.find(query, 0, 0, "g", Gender.FEMALE); + females = jpaSupport.find(query, 0, 0, args); Assert.assertEquals(1, females.size()); Personne charlotte = (Personne) females.get(0); - females = jpaSupport.find(query, 1, 1, "g", Gender.FEMALE); + females = jpaSupport.find(query, 1, 1, args); Assert.assertEquals(1, females.size()); Personne hortense = (Personne) females.get(0); @@ -151,11 +164,15 @@ String query = "from " + Personne.class.getName() + " where " + Personne.PROPERTY_GENDER + "=:g"; - Object male = jpaSupport.findUnique(query, "g", Gender.MALE); + Map<String, Object> args = Maps.newHashMap(); + args.put("g", Gender.MALE); + Object male = jpaSupport.findUnique(query, args); Assert.assertNotNull(male); + args = Maps.newHashMap(); + args.put("pax", "nobody"); Object none = jpaSupport.findUnique("from " + Personne.class.getName() + - " where " + Personne.PROPERTY_NAME + "=:pax", "pax", "nobody"); + " where " + Personne.PROPERTY_NAME + "=:pax", args); Assert.assertNull(none); } @@ -166,7 +183,9 @@ String query = "from " + Personne.class.getName() + " where " + Personne.PROPERTY_GENDER + "=:g"; - Object female = jpaSupport.findUnique(query, "g", Gender.FEMALE); + Map<String, Object> args = Maps.newHashMap(); + args.put("g", Gender.FEMALE); + Object female = jpaSupport.findUnique(query, args); Assert.assertNotNull(female); } Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/HibernateTopiaJpaSupport.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/HibernateTopiaJpaSupport.java 2013-11-26 17:19:25 UTC (rev 2895) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/HibernateTopiaJpaSupport.java 2013-11-27 07:38:49 UTC (rev 2896) @@ -180,32 +180,4 @@ } } - @Override - public <T> List<T> findAll(String jpaql, Object... propertyNamesAndValues) { - Map<String, Object> parameters = TopiaUtil.convertPropertiesArrayToMap(propertyNamesAndValues); - List<T> result = findAll(jpaql, parameters); - return result; - } - - @Override - public <T> List<T> find(String jpaql, int startIndex, int endIndex, Object... propertyNamesAndValues) { - Map<String, Object> parameters = TopiaUtil.convertPropertiesArrayToMap(propertyNamesAndValues); - List<T> result = find(jpaql, startIndex, endIndex, parameters); - return result; - } - - @Override - public <T> T findUnique(String jpaql, Object... propertyNamesAndValues) { - Map<String, Object> parameters = TopiaUtil.convertPropertiesArrayToMap(propertyNamesAndValues); - T result = findUnique(jpaql, parameters); - return result; - } - - @Override - public int execute(String jpaql, Object... propertyNamesAndValues) { - Map<String, Object> parameters = TopiaUtil.convertPropertiesArrayToMap(propertyNamesAndValues); - int result = execute(jpaql, parameters); - return result; - } - } // HibernateTopiaJpaSupport Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaJpaSupport.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaJpaSupport.java 2013-11-26 17:19:25 UTC (rev 2895) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaJpaSupport.java 2013-11-27 07:38:49 UTC (rev 2896) @@ -50,22 +50,6 @@ Map<String, Object> parameters); /** - * Allow to do some JPA-QL query - * <p/> - * WARNING : Depending on the registered service, this method may not - * support something else than queries on TopiaEntity - * - * @param jpaql the JPA-QL query - * @param propertyNamesAndValues the query parameters. Arguments are key-value paired : - * [propertyName;value;propertyName;value;...] - * @return The result list - * @deprecated prefer using {@link #findAll(String, java.util.Map)} - */ - @Deprecated - <T> List<T> findAll(String jpaql, - Object... propertyNamesAndValues); - - /** * Allow to do some JPA-QL query using the given bounds. * <p/> * No lower bound : <code>startIndex</code> = 0.<br/> @@ -74,9 +58,9 @@ * WARNING : Depending on the registered service, this method may not * support something else than queries on TopiaEntity * - * @param jpaql the JPA-QL query - * @param startIndex first index of entity to return - * @param endIndex last index of entity to return + * @param jpaql the JPA-QL query + * @param startIndex first index of entity to return + * @param endIndex last index of entity to return * @param parameters a map which keys are the attribute names and values are the attributes expected values * @return The result list */ @@ -86,29 +70,6 @@ Map<String, Object> parameters); /** - * Allow to do some JPA-QL query using the given bounds. - * <p/> - * No lower bound : <code>startIndex</code> = 0.<br/> - * No upper bound : <code>endIndex</code> = -1. - * <p/> - * WARNING : Depending on the registered service, this method may not - * support something else than queries on TopiaEntity - * - * @param jpaql the JPA-QL query - * @param startIndex first index of entity to return - * @param endIndex last index of entity to return - * @param propertyNamesAndValues the query parameters. Arguments are key-value paired : - * [propertyName;value;propertyName;value;...] - * @return The result list - * @deprecated prefer using {@link #find(String, int, int, java.util.Map)} - */ - @Deprecated - <T> List<T> find(String jpaql, - int startIndex, - int endIndex, - Object... propertyNamesAndValues); - - /** * Allow to do some JPA-QL query and return an unique result. If nothing if * found by the query, will return null. If more than one result is found, * will throw an exception. @@ -116,7 +77,7 @@ * WARNING : Depending on the registered service, this method may not * support something else than queries on TopiaEntity * - * @param jpaql the JPA-QL query + * @param jpaql the JPA-QL query * @param parameters a map which keys are the attribute names and values are the attributes expected values * @return The result instance or null */ @@ -124,27 +85,9 @@ Map<String, Object> parameters); /** - * Allow to do some JPA-QL query and return an unique result. If nothing if - * found by the query, will return null. If more than one result is found, - * will throw an exception. - * <p/> - * WARNING : Depending on the registered service, this method may not - * support something else than queries on TopiaEntity - * - * @param jpaql the JPA-QL query - * @param propertyNamesAndValues the query parameters. Arguments are key-value paired : - * [propertyName;value;propertyName;value;...] - * @return The result instance or null - * @deprecated prefer using {@link #findUnique(String, java.util.Map)} - */ - @Deprecated - <T> T findUnique(String jpaql, - Object... propertyNamesAndValues); - - /** * Execute JPA-QL operation on data (Update, Delete). * - * @param jpaql the JPA-QL query + * @param jpaql the JPA-QL query * @param parameters a map which keys are the attribute names and values are the attributes expected values * @return The number of entities updated or deleted. */ @@ -152,19 +95,6 @@ Map<String, Object> parameters); /** - * Execute JPA-QL operation on data (Update, Delete). - * - * @param jpaql the JPA-QL query - * @param propertyNamesAndValues the query parameters. Arguments are key-value paired : - * [propertyName;value;propertyName;value;...] - * @return The number of entities updated or deleted. - * @deprecated prefer using {@link #execute(String, java.util.Map)} - */ - @Deprecated - int execute(String jpaql, - Object... propertyNamesAndValues); - - /** * Tells to the context if it has to use a flush mode before each query. * <p/> * By default, we use a flush mode, but in some case it costs to much doing
participants (1)
-
athimelï¼ users.nuiton.org