org.nuiton.topia.it.mapping.test17.GeneratedB17TopiaDao Maven / Gradle / Ivy
package org.nuiton.topia.it.mapping.test17;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import javax.annotation.Generated;
import org.hibernate.Session;
import org.nuiton.topia.it.mapping.AbstractTopiaItMappingTopiaDao;
import org.nuiton.topia.it.mapping.TopiaItMappingEntityEnum;
import org.nuiton.topia.persistence.TopiaDao;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.TopiaException;
import org.nuiton.topia.persistence.TopiaQueryBuilderAddCriteriaOrRunQueryStep;
import org.nuiton.topia.persistence.internal.support.HibernateTopiaJpaSupport;
import org.nuiton.topia.persistence.support.TopiaHibernateSupport;
@Generated(value = "org.nuiton.topia.templates.EntityDaoTransformer", date = "Thu Oct 13 17:59:14 CEST 2016")
public abstract class GeneratedB17TopiaDao extends AbstractTopiaItMappingTopiaDao {
@Override
public Class getEntityClass() {
return (Class) B17.class;
}
@Override
public TopiaItMappingEntityEnum getTopiaEntityEnum() {
return TopiaItMappingEntityEnum.B17;
}
@Override
public void delete(E entity) {
if ( ! entity.isPersisted()) {
throw new IllegalArgumentException("entity " + entity + " is not persisted, you can't delete it");
}
TopiaHibernateSupport hibernateSupport = ((HibernateTopiaJpaSupport) topiaJpaSupport).getHibernateSupport();
Session hibernateSession = hibernateSupport.getHibernateSession();
{
String sql = "SELECT main.* " +
" FROM B.bB17 main, B.b17_bb17 secondary " +
" WHERE main.topiaId=secondary.bB17 " +
" AND secondary.b17='" + entity.getTopiaId() + "'";
List list = hibernateSession
.createSQLQuery(sql)
.addEntity("main", TopiaItMappingEntityEnum.BB17.getImplementation())
.list();
for (BB17 item : list) {
item.removeB17(entity);
}
}
super.delete(entity);
}
public TopiaQueryBuilderAddCriteriaOrRunQueryStep forBIn(Collection v) {
TopiaQueryBuilderAddCriteriaOrRunQueryStep result = forIn(B17.PROPERTY_B, (Collection) v);
return result;
}
public TopiaQueryBuilderAddCriteriaOrRunQueryStep forBEquals(int v) {
TopiaQueryBuilderAddCriteriaOrRunQueryStep result = forEquals(B17.PROPERTY_B, v);
return result;
}
@Deprecated
public E findByB(int v) {
return forBEquals(v).findAnyOrNull();
}
@Deprecated
public List findAllByB(int v) {
return forBEquals(v).findAll();
}
@Override
public List findUsages(Class type, E entity) {
List> result = new LinkedList();
List tmp;
if (type == BB17.class) {
BB17TopiaDao dao =
topiaDaoSupplier.getDao(BB17.class, BB17TopiaDao.class);
tmp = dao.forB17Contains(entity).findAll();
result.addAll(tmp);
}
return (List) result;
}
@Override
public Map, List extends TopiaEntity>> findAllUsages(E entity) {
Map,List extends TopiaEntity>> result;
result = new HashMap, List extends TopiaEntity>>(1);
List extends TopiaEntity> list;
list = findUsages(BB17.class, entity);
if (!list.isEmpty()) {
result.put(BB17.class, list);
}
return result;
}
@Override
public List getAggregate(E entity) throws TopiaException {
List tmp = new ArrayList();
// pour tous les attributs rechecher les composites et les class d'asso
// on les ajoute dans tmp
// on refait un tour sur chaque entity de tmp pour recuperer leur
// composite
List result = new ArrayList();
for (TopiaEntity e : tmp) {
result.add(e);
TopiaDao dao = (TopiaDao) topiaDaoSupplier.getDao(e.getClass());
result.addAll(dao.getAggregate(e));
}
return result;
}
@Override
public List getComposite(E entity) throws TopiaException {
List tmp = new ArrayList();
// pour tous les attributs rechecher les composites et les class d'asso
// on les ajoute dans tmp
// on refait un tour sur chaque entity de tmp pour recuperer leur
// composite
List result = new ArrayList();
for (TopiaEntity e : tmp) {
if (e != null) {
result.add(e);
TopiaDao dao = (TopiaDao) topiaDaoSupplier.getDao(e.getClass());
result.addAll(dao.getComposite(e));
}
}
return result;
}
} //GeneratedB17TopiaDao
© 2015 - 2024 Weber Informatics LLC | Privacy Policy