/**
* Example license header for Java files
*
* http://andromda.sourceforge.net/
*/
//
// Attention: Generated code! Do not modify by hand! hibernate4=true hibernateVersion=4
// Generated by hibernate/SpringHibernateDaoBase.vsl in andromda-spring-cartridge on 09/18/2014 17:02:25-0400. Do not modify by hand!.
//
package org.andromda.test.6;
/**
*
* Base Spring DAO Class: is able to create, update, remove, load, and find
* objects of type org.andromda.test.6.Person.
*
*
* @see org.andromda.test.6.Person
*/
@org.springframework.stereotype.Repository
public abstract class PersonDaoBase
implements org.andromda.test.6.PersonDao
{
/**
* For backwards compatibility with HibernateDao method
* @deprecated Use LogFactory.getLog on each subclass, for the correct class name
* Apache commons logging logger used by all subclasses
*/
@Deprecated
protected org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(PersonDaoBase.class);
@javax.annotation.Resource
private org.hibernate.SessionFactory sessionFactory;
/**
* @param sessionFactoryIn
*/
public void setSessionFactory(org.hibernate.SessionFactory sessionFactoryIn) {
this.sessionFactory = sessionFactoryIn;
}
/**
* @return SessionFactory
*/
protected org.hibernate.SessionFactory getSessionFactory() {
return this.sessionFactory;
}
/**
* @return currentSession
*/
protected org.hibernate.Session getSession() {
return this.sessionFactory.getCurrentSession();
}
/**
* For backwards compatibility with HibernateDao method
* @deprecated Use this.sessionFactory.getCurrentSession() instead
* @param ignore boolean - always create new session if needed
* @return currentSession
*/
@Deprecated
protected org.hibernate.Session getSession(boolean ignore) {
return this.getSession();
}
/**
* {@inheritDoc}
*/
@Override
public Object get(final int transform, final java.lang.Long id)
{
if (id == null)
{
throw new IllegalArgumentException(
"Person.get - 'id' can not be null");
}
final Object entity = this.sessionFactory.getCurrentSession().get(org.andromda.test.6.PersonImpl.class, id);
return transformEntity(transform, (org.andromda.test.6.Person)entity);
}
/**
* {@inheritDoc}
*/
@Override
public org.andromda.test.6.Person get(java.lang.Long id)
{
return (org.andromda.test.6.Person)this.get(TRANSFORM_NONE, id);
}
/**
* {@inheritDoc}
*/
@Override
public Object load(final int transform, final java.lang.Long id)
{
if (id == null)
{
throw new IllegalArgumentException(
"Person.load - 'id' can not be null");
}
final Object entity = this.sessionFactory.getCurrentSession().get(org.andromda.test.6.PersonImpl.class, id);
return transformEntity(transform, (org.andromda.test.6.Person)entity);
}
/**
* {@inheritDoc}
*/
@Override
public org.andromda.test.6.Person load(java.lang.Long id)
{
return (org.andromda.test.6.Person)this.load(TRANSFORM_NONE, id);
}
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings({"unchecked"})
public java.util.Collection loadAll()
{
return (java.util.Collection) this.loadAll(org.andromda.test.6.PersonDao.TRANSFORM_NONE);
}
/**
* {@inheritDoc}
*/
@Override
public java.util.Collection> loadAll(final int transform)
{
return this.loadAll(transform, -1, -1);
}
/**
* {@inheritDoc}
*/
@Override
public java.util.Collection> loadAll(final int pageNumber, final int pageSize)
{
return this.loadAll(org.andromda.test.6.PersonDao.TRANSFORM_NONE, pageNumber, pageSize);
}
/**
* {@inheritDoc}
*/
@Override
public java.util.Collection> loadAll(final int transform, final int pageNumber, final int pageSize)
{
final org.hibernate.Criteria criteria = this.sessionFactory.getCurrentSession().createCriteria(org.andromda.test.6.PersonImpl.class);
if (pageNumber > 0 && pageSize > 0)
{
criteria.setFirstResult(this.calculateFirstResult(pageNumber, pageSize));
criteria.setMaxResults(pageSize);
}
final java.util.Collection> results = criteria.list();
this.transformEntities(transform, results);
return results;
}
/**
* firstResult = (pageNumber - 1) * pageSize
* @param pageNumber
* @param pageSize
* @return firstResult
*/
protected int calculateFirstResult(int pageNumber, int pageSize)
{
int firstResult = 0;
if (pageNumber > 0)
{
firstResult = (pageNumber - 1) * pageSize;
}
return firstResult;
}
/**
* prePersist event - This method is called before creating the entity
* @param person org.andromda.test.6.Person
*/
protected void _prePersist(final org.andromda.test.6.Person person)
{
// Abstract method - your implementation goes in the descendant
}
/**
* postPersist event - This method is called after creating the entity
* @param person org.andromda.test.6.Person
*/
protected void _postPersist(final org.andromda.test.6.Person person)
{
// Abstract method - your implementation goes in the descendant
}
/**
* preUpdate event - This method is called before updating the entity
* @param person org.andromda.test.6.Person
*/
protected void _preUpdate(final org.andromda.test.6.Person person)
{
// Abstract method - your implementation goes in the descendant
}
/**
* postUpdate event - This method is called after updating the entity
* @param person org.andromda.test.6.Person
*/
protected void _postUpdate(final org.andromda.test.6.Person person)
{
// Abstract method - your implementation goes in the descendant
}
/**
* preRemove event - This method is called before deleting the entity
* @param person org.andromda.test.6.Person
*/
protected void _preRemove(final org.andromda.test.6.Person person)
{
// Abstract method - your implementation goes in the descendant
}
/**
* postRemove event - This method is called after deleting the entity
* @param person org.andromda.test.6.Person
*/
protected void _postRemove(final org.andromda.test.6.Person person)
{
// Abstract method - your implementation goes in the descendant
}
/**
* {@inheritDoc}
*/
@Override
public org.andromda.test.6.Person create(org.andromda.test.6.Person person)
{
return (org.andromda.test.6.Person)this.create(org.andromda.test.6.PersonDao.TRANSFORM_NONE, person);
}
/**
* {@inheritDoc}
*/
@Override
public Object create(final int transform, final org.andromda.test.6.Person person)
{
if (person == null)
{
throw new IllegalArgumentException(
"Person.create - 'person' can not be null");
}
//prePersist event
_prePersist(person);
this.sessionFactory.getCurrentSession().save(person);
//postPersist event
_postPersist(person);
return this.transformEntity(transform, person);
}
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings({"unchecked"})
public java.util.Collection create(final java.util.Collection entities)
{
return (java.util.Collection) create(org.andromda.test.6.PersonDao.TRANSFORM_NONE, entities);
}
/**
* {@inheritDoc}
*/
@Override
public java.util.Collection> create(final int transform, final java.util.Collection entities)
{
if (entities == null)
{
throw new IllegalArgumentException(
"Person.create - 'entities' can not be null");
}
java.util.Collection