/**
* 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.4;
/**
*
* Base Spring DAO Class: is able to create, update, remove, load, and find
* objects of type org.andromda.test.4.Car
.
*
*
* @see org.andromda.test.4.Car
*/
@org.springframework.stereotype.Repository
public abstract class CarDaoBase
implements org.andromda.test.4.CarDao
{
/**
* 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(CarDaoBase.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(
"Car.get - 'id' can not be null");
}
final Object entity = this.sessionFactory.getCurrentSession().get(org.andromda.test.4.CarImpl.class, id);
return transformEntity(transform, (org.andromda.test.4.Car)entity);
}
/**
* {@inheritDoc}
*/
@Override
public org.andromda.test.4.Car get(java.lang.Long id)
{
return (org.andromda.test.4.Car)this.get(TRANSFORM_NONE, id);
}
/**
* {@inheritDoc}
*/
@Override
public Object load(final int transform, final java.lang.Long id)
{
if (id == null)
{
throw new IllegalArgumentException(
"Car.load - 'id' can not be null");
}
final Object entity = this.sessionFactory.getCurrentSession().get(org.andromda.test.4.CarImpl.class, id);
return transformEntity(transform, (org.andromda.test.4.Car)entity);
}
/**
* {@inheritDoc}
*/
@Override
public org.andromda.test.4.Car load(java.lang.Long id)
{
return (org.andromda.test.4.Car)this.load(TRANSFORM_NONE, id);
}
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings({"unchecked"})
public java.util.Collection loadAll()
{
return (java.util.Collection) this.loadAll(org.andromda.test.4.CarDao.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.4.CarDao.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.4.CarImpl.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 car org.andromda.test.4.Car
*/
protected void _prePersist(final org.andromda.test.4.Car car)
{
}
/**
* postPersist event - This method is called after creating the entity
* @param car org.andromda.test.4.Car
*/
protected void _postPersist(final org.andromda.test.4.Car car)
{
}
/**
* preUpdate event - This method is called before updating the entity
* @param car org.andromda.test.4.Car
*/
protected void _preUpdate(final org.andromda.test.4.Car car)
{
}
/**
* postUpdate event - This method is called after updating the entity
* @param car org.andromda.test.4.Car
*/
protected void _postUpdate(final org.andromda.test.4.Car car)
{
}
/**
* preRemove event - This method is called before deleting the entity
* @param car org.andromda.test.4.Car
*/
protected void _preRemove(final org.andromda.test.4.Car car)
{
}
/**
* postRemove event - This method is called after deleting the entity
* @param car org.andromda.test.4.Car
*/
protected void _postRemove(final org.andromda.test.4.Car car)
{
}
/**
* {@inheritDoc}
*/
@Override
public org.andromda.test.4.Car create(org.andromda.test.4.Car car)
{
return (org.andromda.test.4.Car)this.create(org.andromda.test.4.CarDao.TRANSFORM_NONE, car);
}
/**
* {@inheritDoc}
*/
@Override
public Object create(final int transform, final org.andromda.test.4.Car car)
{
if (car == null)
{
throw new IllegalArgumentException(
"Car.create - 'car' can not be null");
}
//prePersist event
_prePersist(car);
this.sessionFactory.getCurrentSession().save(car);
//postPersist event
_postPersist(car);
return this.transformEntity(transform, car);
}
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings({"unchecked"})
public java.util.Collection create(final java.util.Collection entities)
{
return (java.util.Collection) create(org.andromda.test.4.CarDao.TRANSFORM_NONE, entities);
}
/**
* {@inheritDoc}
*/
@Override
public java.util.Collection> create(final int transform, final java.util.Collection entities)
{
if (entities == null)
{
throw new IllegalArgumentException(
"Car.create - 'entities' can not be null");
}
java.util.Collection transformed = new java.util.ArrayList();
for (org.andromda.test.4.Car entity : entities)
{
transformed.add(create(transform, entity));
}
return transformed;
}
/**
* {@inheritDoc}
*/
@Override
public org.andromda.test.4.Car create(
java.lang.String serial,
java.lang.String name,
java.lang.String type)
{
return (org.andromda.test.4.Car)this.create(org.andromda.test.4.CarDao.TRANSFORM_NONE, serial, name, type);
}
/**
* {@inheritDoc}
*/
@Override
public Object create(
final int transform,
java.lang.String serial,
java.lang.String name,
java.lang.String type)
{
org.andromda.test.4.Car entity = new org.andromda.test.4.CarImpl();
entity.setSerial(serial);
entity.setName(name);
entity.setType(type);
return this.create(transform, entity);
}
/**
* {@inheritDoc}
*/
@Override
public org.andromda.test.4.Car create(
java.lang.String name,
org.andromda.test.4.Person owner,
java.lang.String serial,
java.lang.String type)
{
return (org.andromda.test.4.Car)this.create(org.andromda.test.4.CarDao.TRANSFORM_NONE, name, owner, serial, type);
}
/**
* {@inheritDoc}
*/
@Override
public Object create(
final int transform,
java.lang.String name,
org.andromda.test.4.Person owner,
java.lang.String serial,
java.lang.String type)
{
org.andromda.test.4.Car entity = new org.andromda.test.4.CarImpl();
entity.setName(name);
entity.setOwner(owner);
entity.setSerial(serial);
entity.setType(type);
return this.create(transform, entity);
}
/**
* {@inheritDoc}
*/
@Override
public void update(org.andromda.test.4.Car car)
{
if (car == null)
{
throw new IllegalArgumentException(
"Car.update - 'car' can not be null");
}
//preUpdate event
_preUpdate(car);
this.sessionFactory.getCurrentSession().update(car);
//postUpdate event
_postUpdate(car);
}
/**
* {@inheritDoc}
*/
@Override
public void update(final java.util.Collection entities)
{
if (entities == null)
{
throw new IllegalArgumentException(
"Car.update - 'entities' can not be null");
}
for (org.andromda.test.4.Car entity : entities)
{
update(entity);
}
}
/**
* {@inheritDoc}
*/
@Override
public void remove(org.andromda.test.4.Car car)
{
if (car == null)
{
throw new IllegalArgumentException(
"Car.remove - 'car' can not be null");
}
//preRemove event
_preRemove(car);
this.sessionFactory.getCurrentSession().delete(car);
//postRemove event
_postRemove(car);
}
/**
* {@inheritDoc}
*/
@Override
public void remove(java.lang.Long id)
{
if (id == null)
{
throw new IllegalArgumentException(
"Car.remove - 'id' can not be null");
}
org.andromda.test.4.Car entity = this.get(id);
if (entity != null)
{
this.remove(entity);
}
}
/**
* {@inheritDoc}
*/
@Override
public void remove(java.util.Collection entities)
{
if (entities == null)
{
throw new IllegalArgumentException(
"Car.remove - 'entities' can not be null");
}
for (org.andromda.test.4.Car entity : entities)
{
//preRemove event
_preRemove(entity);
this.sessionFactory.getCurrentSession().delete(entity);
//postRemove event
_postRemove(entity);
}
}
/**
* {@inheritDoc}
*/
@Override
public boolean allCarsAreRented()
{
try
{
return this.handleAllCarsAreRented();
}
catch (Throwable th)
{
throw new RuntimeException(
"Error performing 'org.andromda.test.4.CarDao.allCarsAreRented()' --> " + th,
th);
}
}
/**
* Performs the core logic for {@link #allCarsAreRented()}
* @return boolean
* @throws Exception
*/
protected abstract boolean handleAllCarsAreRented()
throws Exception;
/**
* Allows transformation of entities into value objects
* (or something else for that matter), when the transform
* flag is set to one of the constants defined in org.andromda.test.4.CarDao
, please note
* that the {@link #TRANSFORM_NONE} constant denotes no transformation, so the entity itself
* will be returned.
*
* This method will return instances of these types:
*
* {@link org.andromda.test.4.Car} - {@link #TRANSFORM_NONE}
* {@link org.andromda.test.4.CarDetails} - {@link #TRANSFORM_CARDETAILS}
* {@link org.andromda.test.4.CarListItem} - {@link #TRANSFORM_CARLISTITEM}
*
*
* If the integer argument value is unknown {@link #TRANSFORM_NONE} is assumed.
*
* @param transform one of the constants declared in {@link org.andromda.test.4.CarDao}
* @param entity an entity that was found
* @return the transformed entity (i.e. new value object, etc)
* @see org.andromda.test.4.CarDao#transformEntity(int, org.andromda.test.4.Car)
*/
@Override
public Object transformEntity(final int transform, final org.andromda.test.4.Car entity)
{
Object target = null;
if (entity != null)
{
switch (transform)
{
case TRANSFORM_CARDETAILS :
target = toCarDetails(entity);
break;
case TRANSFORM_CARLISTITEM :
target = toCarListItem(entity);
break;
case org.andromda.test.4.CarDao.TRANSFORM_NONE : // fall-through
default:
target = entity;
}
}
return target;
}
/**
* {@inheritDoc}
*/
@Override
public void transformEntities(final int transform, final java.util.Collection> entities)
{
switch (transform)
{
case TRANSFORM_CARDETAILS :
org.apache.commons.collections.CollectionUtils.transform(entities, this.CARDETAILS_TRANSFORMER);
break;
case TRANSFORM_CARLISTITEM :
org.apache.commons.collections.CollectionUtils.transform(entities, this.CARLISTITEM_TRANSFORMER);
break;
case org.andromda.test.4.CarDao.TRANSFORM_NONE : // fall-through
default:
// do nothing;
}
}
/**
* @see org.andromda.test.4.CarDao#toEntities(java.util.Collection)
*/
@Override
public void toEntities(final java.util.Collection> results)
{
if (results != null)
{
org.apache.commons.collections.CollectionUtils.transform(results, this.ENTITYTRANSFORMER);
}
}
/**
* This anonymous transformer is designed to transform report query results
* (which result in an array of entities) to {@link org.andromda.test.4.Car}
* using the Jakarta Commons-Collections Transformation API.
*/
private org.apache.commons.collections.Transformer ENTITYTRANSFORMER =
new org.apache.commons.collections.Transformer()
{
@Override
public Object transform(Object input)
{
Object result = null;
if (input instanceof Object[])
{
final Object[] rows = (Object[])input;
result = toEntity(rows);
}
else if (input instanceof org.andromda.test.4.Car)
{
result = input;
}
return result;
}
};
/**
* @param row
* @return org.andromda.test.4.Car
*/
protected org.andromda.test.4.Car toEntity(Object[] row)
{
org.andromda.test.4.Car target = null;
if (row != null)
{
final int numberOfObjects = row.length;
for (int ctr = 0; ctr < numberOfObjects; ctr++)
{
final Object object = row[ctr];
if (object instanceof org.andromda.test.4.Car)
{
target = (org.andromda.test.4.Car)object;
break;
}
}
}
return target;
}
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings({"unchecked"})
public final Collection toCarDetailsCollection(java.util.Collection entities)
{
if (entities == null)
{
return null;
}
@SuppressWarnings("rawtypes")
java.util.Collection result = new java.util.ArrayList(entities);
org.apache.commons.collections.CollectionUtils.transform(result, this.CARDETAILS_TRANSFORMER);
return result;
}
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings({ "unchecked" })
public final org.andromda.test.4.CarDetails[] toCarDetailsArray(java.util.Collection> entities)
{
org.andromda.test.4.CarDetails[] result = null;
if (entities != null)
{
@SuppressWarnings("rawtypes")
final java.util.Collection collection = new java.util.ArrayList(entities);
this.toCarDetailsCollection(collection);
result = (org.andromda.test.4.CarDetails[]) collection.toArray(new org.andromda.test.4.CarDetails[collection.size()]);
}
return result;
}
/**
* Default implementation for transforming the results of a report query into a value object. This
* implementation exists for convenience reasons only. It needs only be overridden in the
* {@link CarDaoImpl} class if you intend to use reporting queries.
* @param row
* @return toCarDetails(this.toEntity(row))
* @see org.andromda.test.4.CarDao#toCarDetails(org.andromda.test.4.Car)
*/
protected org.andromda.test.4.CarDetails toCarDetails(Object[] row)
{
return this.toCarDetails(this.toEntity(row));
}
/**
* This anonymous transformer is designed to transform entities or report query results
* (which result in an array of objects) to {@link org.andromda.test.4.CarDetails}
* using the Jakarta Commons-Collections Transformation API.
*/
private org.apache.commons.collections.Transformer CARDETAILS_TRANSFORMER =
new org.apache.commons.collections.Transformer()
{
@Override
public Object transform(Object input)
{
Object result = null;
if (input instanceof org.andromda.test.4.Car)
{
final org.andromda.test.4.Car entity = (org.andromda.test.4.Car)input;
result = toCarDetails(entity);
}
else if (input instanceof Object[])
{
final Object[] rows = (Object[])input;
result = toCarDetails(rows);
}
return result;
}
};
/**
* {@inheritDoc}
*/
@Override
public final void carDetailsToEntityCollection(java.util.Collection> instances)
{
if (instances != null)
{
for (final java.util.Iterator> iterator = instances.iterator(); iterator.hasNext();)
{
// - remove an objects that are null or not of the correct instance
if (!(iterator.next() instanceof org.andromda.test.4.CarDetails))
{
iterator.remove();
}
}
org.apache.commons.collections.CollectionUtils.transform(instances, this.CarDetailsToEntityTransformer);
}
}
private final org.apache.commons.collections.Transformer CarDetailsToEntityTransformer =
new org.apache.commons.collections.Transformer()
{
@Override
public Object transform(Object input)
{
return carDetailsToEntity((org.andromda.test.4.CarDetails)input);
}
};
/**
* {@inheritDoc}
*/
@Override
public void toCarDetails(
org.andromda.test.4.Car source,
org.andromda.test.4.CarDetails target)
{
target.setName(source.getName());
target.setSerial(source.getSerial());
}
/**
* {@inheritDoc}
*/
@Override
public org.andromda.test.4.CarDetails toCarDetails(final org.andromda.test.4.Car entity)
{
org.andromda.test.4.CarDetails target = null;
if (entity != null)
{
target = new org.andromda.test.4.CarDetails();
this.toCarDetails(entity, target);
}
return target;
}
/**
* {@inheritDoc}
*/
@Override
public void carDetailsToEntity(
org.andromda.test.4.CarDetails source,
org.andromda.test.4.Car target,
boolean copyIfNull)
{
if (copyIfNull || source.getSerial() != null)
{
target.setSerial(source.getSerial());
}
if (copyIfNull || source.getName() != null)
{
target.setName(source.getName());
}
}
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings({"unchecked"})
public final Collection toCarListItemCollection(java.util.Collection entities)
{
if (entities == null)
{
return null;
}
@SuppressWarnings("rawtypes")
java.util.Collection result = new java.util.ArrayList(entities);
org.apache.commons.collections.CollectionUtils.transform(result, this.CARLISTITEM_TRANSFORMER);
return result;
}
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings({ "unchecked" })
public final org.andromda.test.4.CarListItem[] toCarListItemArray(java.util.Collection> entities)
{
org.andromda.test.4.CarListItem[] result = null;
if (entities != null)
{
@SuppressWarnings("rawtypes")
final java.util.Collection collection = new java.util.ArrayList(entities);
this.toCarListItemCollection(collection);
result = (org.andromda.test.4.CarListItem[]) collection.toArray(new org.andromda.test.4.CarListItem[collection.size()]);
}
return result;
}
/**
* Default implementation for transforming the results of a report query into a value object. This
* implementation exists for convenience reasons only. It needs only be overridden in the
* {@link CarDaoImpl} class if you intend to use reporting queries.
* @param row
* @return toCarListItem(this.toEntity(row))
* @see org.andromda.test.4.CarDao#toCarListItem(org.andromda.test.4.Car)
*/
protected org.andromda.test.4.CarListItem toCarListItem(Object[] row)
{
return this.toCarListItem(this.toEntity(row));
}
/**
* This anonymous transformer is designed to transform entities or report query results
* (which result in an array of objects) to {@link org.andromda.test.4.CarListItem}
* using the Jakarta Commons-Collections Transformation API.
*/
private org.apache.commons.collections.Transformer CARLISTITEM_TRANSFORMER =
new org.apache.commons.collections.Transformer()
{
@Override
public Object transform(Object input)
{
Object result = null;
if (input instanceof org.andromda.test.4.Car)
{
final org.andromda.test.4.Car entity = (org.andromda.test.4.Car)input;
result = toCarListItem(entity);
}
else if (input instanceof Object[])
{
final Object[] rows = (Object[])input;
result = toCarListItem(rows);
}
return result;
}
};
/**
* {@inheritDoc}
*/
@Override
public final void carListItemToEntityCollection(java.util.Collection> instances)
{
if (instances != null)
{
for (final java.util.Iterator> iterator = instances.iterator(); iterator.hasNext();)
{
// - remove an objects that are null or not of the correct instance
if (!(iterator.next() instanceof org.andromda.test.4.CarListItem))
{
iterator.remove();
}
}
org.apache.commons.collections.CollectionUtils.transform(instances, this.CarListItemToEntityTransformer);
}
}
private final org.apache.commons.collections.Transformer CarListItemToEntityTransformer =
new org.apache.commons.collections.Transformer()
{
@Override
public Object transform(Object input)
{
return carListItemToEntity((org.andromda.test.4.CarListItem)input);
}
};
/**
* {@inheritDoc}
*/
@Override
public void toCarListItem(
org.andromda.test.4.Car source,
org.andromda.test.4.CarListItem target)
{
target.setName(source.getName());
target.setSerial(source.getSerial());
}
/**
* {@inheritDoc}
*/
@Override
public org.andromda.test.4.CarListItem toCarListItem(final org.andromda.test.4.Car entity)
{
org.andromda.test.4.CarListItem target = null;
if (entity != null)
{
target = new org.andromda.test.4.CarListItem();
this.toCarListItem(entity, target);
}
return target;
}
/**
* {@inheritDoc}
*/
@Override
public void carListItemToEntity(
org.andromda.test.4.CarListItem source,
org.andromda.test.4.Car target,
boolean copyIfNull)
{
if (copyIfNull || source.getSerial() != null)
{
target.setSerial(source.getSerial());
}
if (copyIfNull || source.getName() != null)
{
target.setName(source.getName());
}
}
/**
* Gets the current principal
if one has been set,
* otherwise returns null
.
*
* @return the current principal
*/
protected java.security.Principal getPrincipal()
{
return org.andromda.spring.PrincipalStore.get();
}
/**
* {@inheritDoc}
*/
@Override
public org.andromda.spring.PaginationResult search(final int transform, final int pageNumber, final int pageSize, final org.andromda.spring.Search search)
{
search.setPageNumber(pageNumber);
search.setPageSize(pageSize);
final org.andromda.spring.PropertySearch propertySearch = new org.andromda.spring.PropertySearch(
this.sessionFactory.getCurrentSession(), org.andromda.test.4.CarImpl.class, search);
final java.util.List> results = propertySearch.executeAsList();
this.transformEntities(transform, results);
return new org.andromda.spring.PaginationResult(results.toArray(new Object[results.size()]), propertySearch.getTotalCount());
}
/**
* {@inheritDoc}
*/
@Override
public org.andromda.spring.PaginationResult search(final int pageNumber, final int pageSize, final org.andromda.spring.Search search)
{
return this.search(org.andromda.test.4.CarDao.TRANSFORM_NONE, pageNumber, pageSize, search);
}
/**
* {@inheritDoc}
*/
@Override
public java.util.Collection> search(final int transform, final org.andromda.spring.Search search)
{
final org.andromda.spring.PropertySearch propertySearch = new org.andromda.spring.PropertySearch(
this.sessionFactory.getCurrentSession(), org.andromda.test.4.CarImpl.class, search);
final java.util.Collection> results = propertySearch.executeAsList();
this.transformEntities(transform, results);
return results;
}
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings("unchecked")
public java.util.Collection search(final org.andromda.spring.Search search)
{
return (java.util.Collection) this.search(org.andromda.test.4.CarDao.TRANSFORM_NONE, search);
}
/**
* Executes and returns the given Hibernate queryObject as a {@link org.andromda.spring.PaginationResult} instance.
* @param queryObject
* @param transform
* @param pageNumber
* @param pageSize
* @return org.andromda.spring.PaginationResult
*/
@SuppressWarnings({ "unchecked" })
protected org.andromda.spring.PaginationResult getPaginationResult(
final org.hibernate.Query queryObject,
final int transform, int pageNumber, int pageSize)
{
final org.hibernate.ScrollableResults scrollableResults = queryObject.scroll();
scrollableResults.last();
int totalCount = scrollableResults.getRowNumber();
totalCount = totalCount >= 0 ? totalCount + 1 : 0;
if (pageNumber > 0 && pageSize > 0)
{
queryObject.setFirstResult(this.calculateFirstResult(pageNumber, pageSize));
queryObject.setMaxResults(pageSize);
}
// Unchecked transformation because Set object is reused, cannot be strongly typed.
@SuppressWarnings("rawtypes")
java.util.Collection results = new java.util.ArrayList(queryObject.list());
transformEntities(transform, results);
return new org.andromda.spring.PaginationResult(results.toArray(new Object[results.size()]), totalCount);
}
/**
* {@inheritDoc}
*/
@Override
public org.andromda.test.4.Car searchUniqueSerial(final java.lang.String serial)
{
final org.andromda.spring.Search search=new org.andromda.spring.Search(
new org.andromda.spring.SearchParameter[]{
new org.andromda.spring.SearchParameter("serial",serial,org.andromda.spring.SearchParameter.EQUAL_COMPARATOR)
}
);
final java.util.Collection searchResult=this.search(search);
switch(searchResult.size())
{
case 0: return null;
case 1: return searchResult.iterator().next();
default: throw new org.hibernate.NonUniqueResultException(searchResult.size());
}
}
/**
* {@inheritDoc}
*/
@Override
public Object searchUniqueSerial(final int transform, final java.lang.String serial)
{
final org.andromda.test.4.Car entity=this.searchUniqueSerial(serial);
if(entity == null)
{
return null;
}
return transformEntity(transform, entity);
}
/**
* {@inheritDoc}
*/
@Override
public org.andromda.test.4.Car searchUniqueName(final java.lang.String name)
{
final org.andromda.spring.Search search=new org.andromda.spring.Search(
new org.andromda.spring.SearchParameter[]{
new org.andromda.spring.SearchParameter("name",name,org.andromda.spring.SearchParameter.EQUAL_COMPARATOR)
}
);
final java.util.Collection searchResult=this.search(search);
switch(searchResult.size())
{
case 0: return null;
case 1: return searchResult.iterator().next();
default: throw new org.hibernate.NonUniqueResultException(searchResult.size());
}
}
/**
* {@inheritDoc}
*/
@Override
public Object searchUniqueName(final int transform, final java.lang.String name)
{
final org.andromda.test.4.Car entity=this.searchUniqueName(name);
if(entity == null)
{
return null;
}
return transformEntity(transform, entity);
}
/**
* {@inheritDoc}
*/
@Override
public org.andromda.test.4.Car searchUniqueType(final java.lang.String type)
{
final org.andromda.spring.Search search=new org.andromda.spring.Search(
new org.andromda.spring.SearchParameter[]{
new org.andromda.spring.SearchParameter("type",type,org.andromda.spring.SearchParameter.EQUAL_COMPARATOR)
}
);
final java.util.Collection searchResult=this.search(search);
switch(searchResult.size())
{
case 0: return null;
case 1: return searchResult.iterator().next();
default: throw new org.hibernate.NonUniqueResultException(searchResult.size());
}
}
/**
* {@inheritDoc}
*/
@Override
public Object searchUniqueType(final int transform, final java.lang.String type)
{
final org.andromda.test.4.Car entity=this.searchUniqueType(type);
if(entity == null)
{
return null;
}
return transformEntity(transform, entity);
}
/**
* Create or Update the car
instance in the persistent store.
* @param car
*/
@Override
public org.andromda.test.4.Car createOrUpdate(org.andromda.test.4.Car car)
{
if(car.getId() == null)
{
return (org.andromda.test.4.Car)this.create(TRANSFORM_NONE,car);
}
this.update(car);
return car;
}
// spring-hibernate-dao-base merge-point
}