Index: topia/src/java/org/codelutin/topia/AbstractTopiaPersistenceService.java diff -u topia/src/java/org/codelutin/topia/AbstractTopiaPersistenceService.java:1.12 topia/src/java/org/codelutin/topia/AbstractTopiaPersistenceService.java:1.13 --- topia/src/java/org/codelutin/topia/AbstractTopiaPersistenceService.java:1.12 Thu Aug 11 16:35:23 2005 +++ topia/src/java/org/codelutin/topia/AbstractTopiaPersistenceService.java Fri Aug 26 17:53:35 2005 @@ -23,10 +23,10 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.12 $ + * @version $Revision: 1.13 $ * - * Mise a jour: $Date: 2005/08/11 16:35:23 $ - * par : $Author: thimel $ + * Mise a jour: $Date: 2005/08/26 17:53:35 $ + * par : $Author: bpoussin $ */ package org.codelutin.topia; @@ -76,6 +76,9 @@ } public Entity makePersistent(Entity topiaEntity)throws TopiaException{ + if(!getEntityClass().isAssignableFrom(topiaEntity.getClass())){ + throw new TopiaException("Wrong persistence service. You should use the entity related persistence service"); + } Entity result = (Entity)getContext().getPersistenceHelper().makePersistent(topiaEntity); try { getContext().getListeners().fire(this.getClass(), "entityAdded", new TopiaEntityEvent(this, result)); @@ -86,6 +89,9 @@ } public Entity update(Entity topiaEntity) throws TopiaException{ + if(!getEntityClass().isAssignableFrom(topiaEntity.getClass())){ + throw new TopiaException("Wrong persistence service. You should use the entity related persistence service"); + } Entity result = (Entity)getContext().getPersistenceHelper().update(topiaEntity); try { getContext().getListeners().fire(this.getClass(), "entityModified", new TopiaEntityEvent(this, result)); @@ -96,6 +102,9 @@ } public void delete(Entity topiaEntity) throws TopiaException{ + if(!getEntityClass().isAssignableFrom(topiaEntity.getClass())){ + throw new TopiaException("Wrong persistence service. You should use the entity related persistence service"); + } getContext().getPersistenceHelper().delete(topiaEntity); try { getContext().getListeners().fire(this.getClass(), "entityRemoved", new TopiaEntityEvent(this, topiaEntity)); Index: topia/src/java/org/codelutin/topia/TopiaQuery.java diff -u topia/src/java/org/codelutin/topia/TopiaQuery.java:1.6 topia/src/java/org/codelutin/topia/TopiaQuery.java:1.7 --- topia/src/java/org/codelutin/topia/TopiaQuery.java:1.6 Wed Sep 15 15:26:22 2004 +++ topia/src/java/org/codelutin/topia/TopiaQuery.java Fri Aug 26 17:53:35 2005 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ * - * Mise a jour: $Date: 2004/09/15 15:26:22 $ + * Mise a jour: $Date: 2005/08/26 17:53:35 $ * par : $Author: bpoussin $ */ @@ -81,17 +81,17 @@ public String getQueryString(){ StringBuffer result = new StringBuffer(); - result.append("SELECT "); + result.append("SELECT"); if(limitMin != -1 && limitMax != -1){ - result.append(" LIMIT " + limitMin + ", " + limitMax); + result.append(" LIMIT " + limitMin + " " + limitMax); } - result.append(select); + result.append(" " + select); result.append(" FROM " + from); if(where != null && !where.equals("")){ result.append(" WHERE " + where); } if(orderby != null && !orderby.equals("")){ - result.append(" order by " + orderby); + result.append(" ORDER BY " + orderby); } return result.toString(); } @@ -146,7 +146,14 @@ return this; } /** - * attend le classe d'un entity. org.codelutin.chorem.Customer + * attend la classe d'un entity. org.codelutin.chorem.Customer + */ + public TopiaQuery from(Class v){ + from = v.getName(); + return this; + } + /** + * attend la classe d'un entity. org.codelutin.chorem.Customer */ public TopiaQuery from(String v){ from = v;