// license-header java merge-point // // Attention: Generated code! Do not modify by hand! // Generated by: SessionDaoBase.vsl in andromda-ejb3-cartridge. // package com.agcs.amd2.model.util; /** *

* Base EJB3 DAO Class: is able to create, update, remove, load, and find * objects of type com.agcs.amd2.model.util.Information. *

* * @see com.agcs.amd2.model.util.InformationDao */ public abstract class InformationDaoBase implements com.agcs.amd2.model.util.InformationDao { // ------ Session Context Injection ------ @javax.annotation.Resource protected javax.ejb.SessionContext context; // ------ Persistence Context Injection -------- /** * Inject persistence context amanda2 */ @org.jboss.seam.annotations.In("entityManager") private javax.persistence.EntityManager emanager; public javax.persistence.EntityManager getEntityManager () { if( emanager==null) // Not injected { return com.agcs.amd2.model.LocalEntityManager.getCurrentEntityManager(); } else return emanager; } /** * Injext Hibernate Session */ private org.hibernate.Session hibernateSession; public org.hibernate.Session getHibernateSession () { if( hibernateSession==null) // Not injected return (org.hibernate.Session) getEntityManager().getDelegate (); else return hibernateSession; } /** * @see com.agcs.amd2.model.util.InformationDao#load(int,) */ public Object load(final int transform, final java.lang.Long id) throws com.agcs.amd2.model.util.DaoException { if (id == null) { throw new IllegalArgumentException( "Information.load - 'id' can not be null"); } try { final Object entity = (com.agcs.amd2.model.util.Information)getEntityManager().find(com.agcs.amd2.model.util.Information.class, id); return transformEntity(transform, (com.agcs.amd2.model.util.Information)entity); } catch (Exception ex) { throw new com.agcs.amd2.model.util.DaoException(ex); } } /** * @see com.agcs.amd2.model.util.InformationDao#load() */ public com.agcs.amd2.model.util.Information load( final java.lang.Long id) throws com.agcs.amd2.model.util.DaoException { return (com.agcs.amd2.model.util.Information)this.load(TRANSFORM_NONE, id); } /** * @see com.agcs.amd2.model.util.InformationDao#loadAll() */ @SuppressWarnings({"unchecked"}) public java.util.Collection loadAll() throws com.agcs.amd2.model.util.DaoException { return (java.util.Collection)this.loadAll(TRANSFORM_NONE); } /** * @see com.agcs.amd2.model.util.InformationDao#loadAll(int) */ public java.util.Collection loadAll(final int transform) throws com.agcs.amd2.model.util.DaoException { try { javax.persistence.Query query = getEntityManager().createNamedQuery("Information.findAll"); java.util.List results = query.getResultList(); this.transformEntities(transform, results); return results; } catch (Exception ex) { throw new com.agcs.amd2.model.util.DaoException(ex); } } /** * @see com.agcs.amd2.model.util.InformationDao#create(com.agcs.amd2.model.util.Information) */ public com.agcs.amd2.model.util.Information create(com.agcs.amd2.model.util.Information information) throws com.agcs.amd2.model.util.DaoException { return (com.agcs.amd2.model.util.Information)this.create(TRANSFORM_NONE, information); } /** * @see com.agcs.amd2.model.util.InformationDao#create(int transform, com.agcs.amd2.model.util.Information) */ public Object create(final int transform, final com.agcs.amd2.model.util.Information information) throws com.agcs.amd2.model.util.DaoException { if (information == null) { throw new IllegalArgumentException( "Information.create - 'information' can not be null"); } try { getEntityManager().persist(information); getEntityManager().flush(); return this.transformEntity(transform, information); } catch (Exception ex) { throw new com.agcs.amd2.model.util.DaoException(ex); } } /** * @see com.agcs.amd2.model.util.InformationDao#create(java.util.Collection) */ @SuppressWarnings({"unchecked"}) public java.util.Collection create(final java.util.Collection entities) throws com.agcs.amd2.model.util.DaoException { return create(TRANSFORM_NONE, entities); } /** * @see com.agcs.amd2.model.util.InformationDao#create(int, java.util.Collection) */ @SuppressWarnings({"unchecked"}) public java.util.Collection create(final int transform, final java.util.Collection entities) throws com.agcs.amd2.model.util.DaoException { if (entities == null) { throw new IllegalArgumentException( "Information.create - 'entities' can not be null"); } java.util.Collection results = new java.util.ArrayList(); try { for (final java.util.Iterator entityIterator = entities.iterator(); entityIterator.hasNext();) { results.add(create(transform, (com.agcs.amd2.model.util.Information)entityIterator.next())); } } catch (Exception ex) { throw new com.agcs.amd2.model.util.DaoException(ex); } return results; } /** * @see com.agcs.amd2.model.util.InformationDao#create(int, java.lang.String) */ public com.agcs.amd2.model.util.Information create( int version, java.lang.String comment) throws com.agcs.amd2.model.util.DaoException { return (com.agcs.amd2.model.util.Information)this.create(TRANSFORM_NONE, version, comment); } /** * @see com.agcs.amd2.model.util.InformationDao#create(int, int, java.lang.String) */ public Object create( final int transform, int version, java.lang.String comment) throws com.agcs.amd2.model.util.DaoException { com.agcs.amd2.model.util.Information entity = new com.agcs.amd2.model.util.Information(); entity.setVersion(version); entity.setComment(comment); return this.create(transform, entity); } /** * @see com.agcs.amd2.model.util.InformationDao#update(com.agcs.amd2.model.util.Information) */ public void update(com.agcs.amd2.model.util.Information information) throws com.agcs.amd2.model.util.DaoException { if (information == null) { throw new IllegalArgumentException( "Information.update - 'information' can not be null"); } try { getEntityManager().merge(information); getEntityManager().flush(); } catch (Exception ex) { throw new com.agcs.amd2.model.util.DaoException(ex); } } /** * @see com.agcs.amd2.model.util.InformationDao#update(java.util.Collection) */ public void update(final java.util.Collection entities) throws com.agcs.amd2.model.util.DaoException { if (entities == null) { throw new IllegalArgumentException( "Information.update - 'entities' can not be null"); } try { for (final java.util.Iterator entityIterator = entities.iterator(); entityIterator.hasNext();) { update((com.agcs.amd2.model.util.Information)entityIterator.next()); } } catch (Exception ex) { throw new com.agcs.amd2.model.util.DaoException(ex); } } /** * @see com.agcs.amd2.model.util.InformationDao#remove(com.agcs.amd2.model.util.Information) */ public void remove(com.agcs.amd2.model.util.Information information) throws com.agcs.amd2.model.util.DaoException { if (information == null) { throw new IllegalArgumentException( "Information.remove - 'information' can not be null"); } try { getEntityManager().remove(information); getEntityManager().flush(); } catch (Exception ex) { throw new com.agcs.amd2.model.util.DaoException(ex); } } /** * @see com.agcs.amd2.model.util.InformationDao#remove(java.lang.Long) */ public void remove(java.lang.Long id) throws com.agcs.amd2.model.util.DaoException { if (id == null) { throw new IllegalArgumentException( "Information.remove - 'id' can not be null"); } try { final com.agcs.amd2.model.util.Information entity = this.load(id); if (entity != null) { this.remove(entity); } } catch (Exception ex) { throw new com.agcs.amd2.model.util.DaoException(ex); } } /** * @see com.agcs.amd2.model.util.InformationDao#remove(java.util.Collection) */ public void remove(java.util.Collection entities) throws com.agcs.amd2.model.util.DaoException { if (entities == null) { throw new IllegalArgumentException( "Information.remove - 'entities' can not be null"); } try { for (final java.util.Iterator entityIterator = entities.iterator(); entityIterator.hasNext();) { remove((com.agcs.amd2.model.util.Information)entityIterator.next()); } } catch (Exception ex) { throw new com.agcs.amd2.model.util.DaoException(ex); } } /** * @see com.agcs.amd2.model.util.InformationDao#getLastVersion() */ public java.lang.Integer getLastVersion() throws com.agcs.amd2.model.util.DaoException { return (java.lang.Integer)this.getLastVersion(TRANSFORM_NONE); } /** * @see com.agcs.amd2.model.util.InformationDao#getLastVersion(java.lang.String) */ public java.lang.Integer getLastVersion(final java.lang.String queryString) throws com.agcs.amd2.model.util.DaoException { return (java.lang.Integer)this.getLastVersion(TRANSFORM_NONE, queryString); } /** * @see com.agcs.amd2.model.util.InformationDao#getLastVersion(int) */ public Object getLastVersion(final int transform) throws com.agcs.amd2.model.util.DaoException { try { if (false) { /* Commented out because it is an abstract query */ javax.persistence.Query queryObject = null; Object result = queryObject.getSingleResult(); result = transformEntity(transform, (com.agcs.amd2.model.util.Information)result); return result; } /* We close the commenting of abstract queries */ return null; } catch (Exception ex) { throw new com.agcs.amd2.model.util.DaoException(ex); } } /** * @see com.agcs.amd2.model.util.InformationDao#getLastVersion(int, java.lang.String) */ public Object getLastVersion(final int transform, final java.lang.String queryString) throws com.agcs.amd2.model.util.DaoException { try { javax.persistence.Query queryObject = getEntityManager().createQuery(queryString); Object result = queryObject.getSingleResult(); result = transformEntity(transform, (com.agcs.amd2.model.util.Information)result); return result; } catch (Exception ex) { throw new com.agcs.amd2.model.util.DaoException(ex); } } /** * 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 com.agcs.amd2.model.util.InformationDao, please note * that the {@link #TRANSFORM_NONE} constant denotes no transformation, so the entity itself * will be returned. * * If the integer argument value is unknown {@link #TRANSFORM_NONE} is assumed. * * @param transform one of the constants declared in {@link com.agcs.amd2.model.util.InformationDao} * @param entity an entity that was found * @return the transformed entity (i.e. new value object, etc) * @see #transformEntities(int,java.util.Collection) */ protected Object transformEntity(final int transform, final com.agcs.amd2.model.util.Information entity) { Object target = null; if (entity != null) { switch (transform) { case TRANSFORM_NONE : // fall-through default: target = entity; } } return target; } /** * Transforms a collection of entities using the * {@link #transformEntity(int, com.agcs.amd2.model.util.Information)} * method. This method does not instantiate a new collection. *

* This method is to be used internally only. * * @param transform one of the constants declared in com.agcs.amd2.model.util.InformationDao * @param entities the collection of entities to transform * @return the same collection as the argument, but this time containing the transformed entities * @see #transformEntity(int, com.agcs.amd2.model.util.Information) */ protected void transformEntities(final int transform, final java.util.Collection entities) { switch (transform) { case TRANSFORM_NONE : // fall-through default: // do nothing; } } }