package com.wasc.swiftcambio.home;
import java.util.*;
import org.apache.commons.logging.*;
import javax.naming.InitialContext;
import org.hibernate.*;
import com.wasc.swiftcambio.Client;
import static org.hibernate.criterion.Example.*;
/**
* Home object for domain model class Client.
* @see com.wasc.swiftcambio.Client
* @author Hibernate Tools
*/
public class ClientHome {
private static final Log log = LogFactory.getLog(Client.class);
private final SessionFactory sessionFactory = getSessionFactory();
protected SessionFactory getSessionFactory() {
try {
return (SessionFactory) new InitialContext().lookup("SessionFactory");
}
catch (Exception e) {
log.error("Could not locate SessionFactory in JNDI", e);
throw new IllegalStateException("Could not locate SessionFactory in JNDI");
}
}
public void persist(Client transientInstance) {
log.debug("persisting Client instance");
try {
sessionFactory.getCurrentSession().persist(transientInstance);
log.debug("persist successful");
}
catch (RuntimeException re) {
log.error("persist failed", re);
throw re;
}
}
public void attachDirty(Client instance) {
log.debug("attaching dirty Client instance");
try {
sessionFactory.getCurrentSession().saveOrUpdate(instance);
log.debug("attach successful");
}
catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Client instance) {
log.debug("attaching clean Client instance");
try {
sessionFactory.getCurrentSession().lock(instance, LockMode.NONE);
log.debug("attach successful");
}
catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void delete(Client persistentInstance) {
log.debug("deleting Client instance");
try {
sessionFactory.getCurrentSession().delete(persistentInstance);
log.debug("delete successful");
}
catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Client merge(Client detachedInstance) {
log.debug("merging Client instance");
try {
Client result = (Client) sessionFactory.getCurrentSession()
.merge(detachedInstance);
log.debug("merge successful");
return result;
}
catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public Client findById(String id) {
log.debug("getting Client instance with id: " + id);
try {
Client instance = (Client) sessionFactory.getCurrentSession()
.get("com.wasc.swiftcambio.Client", id);
if (instance==null) {
log.debug("get successful, no instance found");
}
else {
log.debug("get successful, instance found");
}
return instance;
}
catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Client instance) {
log.debug("finding Client instance by example");
try {
List results = sessionFactory.getCurrentSession()
.createCriteria("com.wasc.swiftcambio.Client")
.add( create(instance) )
.list();
log.debug("find by example successful, result size: " + results.size());
return results;
}
catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}
}
|