本文整理汇总了Java中net.sf.hibernate.Session类的典型用法代码示例。如果您正苦于以下问题:Java Session类的具体用法?Java Session怎么用?Java Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Session类属于net.sf.hibernate包,在下文中一共展示了Session类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getSession
import net.sf.hibernate.Session; //导入依赖的package包/类
Session getSession(JCASessionImpl handle) {
// JCA 1.0, 5.5.4
// Ensure that there is at most one connection handle associated
// actively with a ManagedConnection instance. [skiped] Any operations
// on the ManagedConnection from any previously created connection
// handles should result in an application level exception.
// this might be pretty bad for performance, profile and find a
// better way if it is really bad
synchronized (handles) {
if ( handles.size() > 0 && handles.get(0) == handle) {
return session;
}
else {
final String message = "Inactive logical session handle called";
// cannot throw HibernateException because not all Session
// methods throws it. This is incompatible with the spec!
throw new IllegalStateException(message);
}
}
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:22,代码来源:ManagedConnectionImpl.java
示例2: lookup
import net.sf.hibernate.Session; //导入依赖的package包/类
/**
* Retrieve the persistent object bound to the given name.
* @see org.odmg.Database#lookup(String)
*/
public Object lookup(String name) throws ObjectNameNotFoundException {
try {
Session s = getSession();
Name nameObj;
try {
nameObj = (Name) s.load(Name.class, name);
}
catch (ObjectNotFoundException onfe) {
throw new ObjectNameNotFoundException();
}
return s.load( nameObj.getPersistentClass(), nameObj.getId() );
}
catch (HibernateException he) {
throw new ODMGRuntimeException( he.getMessage() );
}
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:Database.java
示例3: unbind
import net.sf.hibernate.Session; //导入依赖的package包/类
/**
* Unbind the given name.
* @see org.odmg.Database#unbind(String)
*/
public void unbind(String name) throws ObjectNameNotFoundException {
try {
Session s = getSession();
Name nameObj;
try {
nameObj = (Name) s.load(Name.class, name);
}
catch (ObjectNotFoundException onfe) {
throw new ObjectNameNotFoundException();
}
s.delete(nameObj);
}
catch (HibernateException he) {
throw new ODMGRuntimeException( he.getMessage() );
}
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:Database.java
示例4: changeUserDetails
import net.sf.hibernate.Session; //导入依赖的package包/类
/**
* Demonstrates detached object support
*/
public void changeUserDetails(User user) throws Exception {
System.out.println("Changing user details for: " + user.getId() );
Session s = factory.openSession();
Transaction tx=null;
try {
tx = s.beginTransaction();
s.saveOrUpdate(user);
tx.commit();
}
catch (Exception e) {
if (tx!=null) tx.rollback();
throw e;
}
finally {
s.close();
}
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:Main.java
示例5: changeItemDescription
import net.sf.hibernate.Session; //导入依赖的package包/类
/**
* Demonstrates automatic dirty checking
*/
public void changeItemDescription(Long itemId, String description) throws Exception {
System.out.println("Changing auction item description for: " + itemId );
Session s = factory.openSession();
Transaction tx=null;
try {
tx = s.beginTransaction();
AuctionItem item = (AuctionItem) s.get(AuctionItem.class, itemId);
if (item==null) throw new IllegalArgumentException("No item for the given id: " + itemId);
item.setDescription(description);
tx.commit();
}
catch (Exception e) {
if (tx!=null) tx.rollback();
throw e;
}
finally {
s.close();
}
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:Main.java
示例6: saveChangeList
import net.sf.hibernate.Session; //导入依赖的package包/类
private int saveChangeList(final ChangeList chl, final Session session) throws HibernateException {
session.saveOrUpdate(chl);
// set synthetic change list number if necessary
final int changeListID = chl.getChangeListID();
if (StringUtils.isBlank(chl.getNumber())) {
chl.setNumber(Integer.toString(changeListID));
session.saveOrUpdate(chl);
}
for (final Iterator iter = chl.getChanges().iterator(); iter.hasNext(); ) {
final Change ch = (Change) iter.next();
if (ch.getChangeListID() == ChangeList.UNSAVED_ID) {
ch.setChangeListID(changeListID);
}
session.saveOrUpdate(ch);
}
return changeListID;
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:18,代码来源:ConfigurationManager.java
示例7: getStatsFromDB
import net.sf.hibernate.Session; //导入依赖的package包/类
/**
* Returns list of PersistentObject corresponding the type of
* the statistics.
*
* @param session
* @param buildID
* @param fromDate
* @return
* @throws HibernateException
*/
protected List getStatsFromDB(final Session session, final int buildID, final Date fromDate,
final Date toDate) throws HibernateException {
final Query q = session.createQuery("select ms from MonthlyTestStats ms " +
" where ms.activeBuildID = ? " +
" and ms.testCode = ? " +
" and ms.sampleTime >= ? " +
" and ms.sampleTime <= ?");
q.setCacheable(true);
q.setInteger(0, buildID);
q.setByte(1, getTestCode());
q.setDate(2, fromDate);
q.setDate(3, toDate);
return q.list();
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:YearlyPersistentTestStatsRetriever.java
示例8: getStatsFromDB
import net.sf.hibernate.Session; //导入依赖的package包/类
/**
* Returns list of PersistentObject corresponding the type of
* the statistics.
*
* @param session
* @param buildID
* @param fromDate
* @return
* @throws HibernateException
*/
protected List getStatsFromDB(final Session session, final int buildID, final Date fromDate,
final Date toDate) throws HibernateException {
final Query q = session.createQuery("select hts from HourlyTestStats hts " +
" where hts.activeBuildID = ? " +
" and hts.testCode = ? " +
" and hts.sampleTime >= ? " +
" and hts.sampleTime <= ?");
q.setCacheable(true);
q.setInteger(0, buildID);
q.setByte(1, getTestCode());
q.setDate(2, fromDate);
q.setDate(3, toDate);
return q.list();
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:HourlyPersistentTestStatsRetriever.java
示例9: getStatsFromDB
import net.sf.hibernate.Session; //导入依赖的package包/类
/**
* Returns list of PersistentObject corresponding the type of
* the statistics.
*
* @param session
* @param buildID
* @param fromDate
* @return
* @throws HibernateException
*/
protected List getStatsFromDB(final Session session, final int buildID, final Date fromDate,
final Date toDate) throws HibernateException {
final Query q = session.createQuery("select mts from MonthlyTestStats mts " +
" where mts.activeBuildID = ? " +
" and mts.testCode = ? " +
" and mts.sampleTime >= ? " +
" and mts.sampleTime <= ?");
q.setCacheable(true);
q.setInteger(0, buildID);
q.setByte(1, getTestCode());
q.setDate(2, fromDate);
q.setDate(3, toDate);
return q.list();
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:MonthlyPersistentTestStatsRetriever.java
示例10: getStatsFromDB
import net.sf.hibernate.Session; //导入依赖的package包/类
/**
* Returns list of PersistentObject corresponding the type of
* the statistics.
*
* @param session
* @param buildID
* @param fromDate
* @return
* @throws HibernateException
*/
protected List getStatsFromDB(final Session session, final int buildID, final Date fromDate,
final Date toDate) throws HibernateException {
final Query q = session.createQuery("select dts from DailyTestStats dts " +
" where dts.activeBuildID = ? " +
" and dts.testCode = ? " +
" and dts.sampleTime >= ? " +
" and dts.sampleTime <= ?");
q.setCacheable(true);
q.setInteger(0, buildID);
q.setByte(1, getTestCode());
q.setDate(2, fromDate);
q.setDate(3, toDate);
return q.list();
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:26,代码来源:DailyPersistentTestStatsRetriever.java
示例11: obtenerPermiso
import net.sf.hibernate.Session; //导入依赖的package包/类
/**
* @ejb.interface-method
* @ejb.permission role-name="${role.gestor},${role.admin},${role.auto}"
*/
public Permiso obtenerPermiso(Long codigo) {
Session session = getSession();
try {
// Cargamos permiso
Permiso permiso = (Permiso) session.load(Permiso.class, codigo);
return permiso;
} catch (ObjectNotFoundException onfe) {
return null;
} catch (HibernateException he) {
throw new EJBException(he);
} finally {
close(session);
}
}
开发者ID:GovernIB,项目名称:sistra,代码行数:20,代码来源:PermisoFacadeEJB.java
示例12: grabarPermiso
import net.sf.hibernate.Session; //导入依赖的package包/类
/**
* @ejb.interface-method
* @ejb.permission role-name="${role.admin}"
*/
public Long grabarPermiso(Permiso obj) {
Session session = getSession();
try {
if(obj.getCodigo()!=null)
session.update(obj);
else
session.save(obj);
return obj.getCodigo();
} catch (HibernateException he) {
throw new EJBException(he);
} finally {
close(session);
}
}
开发者ID:GovernIB,项目名称:sistra,代码行数:22,代码来源:PermisoFacadeEJB.java
示例13: listarPuntosSalidaFormulario
import net.sf.hibernate.Session; //导入依赖的package包/类
/**
* Lista todos los puntos salida de un formulario
* @ejb.interface-method
* @ejb.permission unchecked="true"
*/
public List listarPuntosSalidaFormulario(Long idFormulario) {
Session session = getSession();
try {
List puntosSalida = new ArrayList();
Formulario formulario = (Formulario)session.load(Formulario.class, idFormulario);
List salidas = formulario.getSalidas();
for (int i = 0; i < salidas.size(); i++) {
Salida salida = (Salida) salidas.get(i);
puntosSalida.add(salida.getPunto());
}
return puntosSalida;
} catch (HibernateException he) {
throw new EJBException(he);
} finally {
close(session);
}
}
开发者ID:GovernIB,项目名称:sistra,代码行数:24,代码来源:PuntoSalidaFacadeEJB.java
示例14: grabarNuevaNotificacionTelematica
import net.sf.hibernate.Session; //导入依赖的package包/类
/**
* @ejb.interface-method
* @ejb.permission role-name="${role.gestor}"
* @ejb.permission role-name="${role.auto}"
*/
public Long grabarNuevaNotificacionTelematica(NotificacionTelematica obj) {
Session session = getSession();
try {
if (obj.getCodigo() == null){
session.save(obj);
}else{
throw new Exception("No se permite actualizar notificacion telematica");
}
return obj.getCodigo();
} catch (Exception he) {
throw new EJBException(he);
} finally {
close(session);
}
}
开发者ID:GovernIB,项目名称:sistra,代码行数:23,代码来源:NotificacionTelematicaFacadeEJB.java
示例15: gravarComponentePaleta
import net.sf.hibernate.Session; //导入依赖的package包/类
/**
* Crea o actualiza un componente de una paleta.
* @ejb.interface-method
* @ejb.permission role-name="${role.admin}"
*/
public void gravarComponentePaleta(Componente componente, Long paleta_id) {
Session session = getSession();
try {
if (componente.getId() == null) {
Paleta paleta = (Paleta) session.load(Paleta.class, paleta_id);
paleta.addComponente(componente);
session.flush();
} else {
session.update(componente);
}
} catch (HibernateException he) {
throw new EJBException(he);
} finally {
close(session);
}
}
开发者ID:GovernIB,项目名称:sistra,代码行数:22,代码来源:ComponenteFacadeEJB.java
示例16: listarCuentas
import net.sf.hibernate.Session; //导入依赖的package包/类
/**
* @ejb.interface-method
* @ejb.permission role-name="${role.admin}"
*/
public List listarCuentas()
{
Session session = getSession();
try
{
Query query = session.createQuery( "FROM Cuenta c");
query.setCacheable( true );
return query.list();
}
catch (HibernateException he)
{
throw new EJBException(he);
}
finally
{
close(session);
}
}
开发者ID:GovernIB,项目名称:sistra,代码行数:24,代码来源:CuentaFacadeEJB.java
示例17: recuperarEventoPorId
import net.sf.hibernate.Session; //导入依赖的package包/类
private EventoExpediente recuperarEventoPorId(Long id) {
Session session = getSession();
try
{
EventoExpediente eventoExpediente = ( EventoExpediente ) session.load( EventoExpediente.class, id );
Hibernate.initialize( eventoExpediente.getDocumentos() );
return eventoExpediente;
}
catch (HibernateException he)
{
throw new EJBException(he);
}
finally
{
close(session);
}
}
开发者ID:GovernIB,项目名称:sistra,代码行数:18,代码来源:EventoExpedienteFacadeEJB.java
示例18: buscarIndice
import net.sf.hibernate.Session; //导入依赖的package包/类
/**
* Busca en los indices del usuario autenticado por la palabra clave.
*
* @ejb.interface-method
* @ejb.permission role-name="${role.todos}"
*/
public List buscarIndice(String nif, String palabraClave) {
Session session = getSession();
try
{
Query query = session
.createQuery( "FROM IndiceElemento e where e.nif= :nif and upper(e.valor) like :clave" )
.setParameter("nif",nif)
.setParameter("clave","%" + palabraClave.toUpperCase() + "%");
return query.list();
}
catch (HibernateException he)
{
throw new EJBException(he);
}
finally
{
close(session);
}
}
开发者ID:GovernIB,项目名称:sistra,代码行数:26,代码来源:IndiceElementoFacadeEJB.java
示例19: recuperarElementoExpedientePorCodigo
import net.sf.hibernate.Session; //导入依赖的package包/类
private ElementoExpediente recuperarElementoExpedientePorCodigo( Long id )
{
Session session = getSession();
try
{
ElementoExpediente elementoExpediente = ( ElementoExpediente ) session.load( ElementoExpediente.class, id );
return elementoExpediente;
}
catch (HibernateException he)
{
throw new EJBException(he);
}
finally
{
close(session);
}
}
开发者ID:GovernIB,项目名称:sistra,代码行数:18,代码来源:ElementoExpedienteFacadeEJB.java
示例20: resuelveRDS
import net.sf.hibernate.Session; //导入依赖的package包/类
/**
* Resuelve referencia RDS a partir del c�digo de documento
* @param codigoRDS
* @return
*/
public ReferenciaRDS resuelveRDS(long codigoRDS) throws Exception{
Session session = getSession();
try {
Documento documento;
documento = (Documento) session.load(Documento.class, new Long(codigoRDS));
ReferenciaRDS ref = new ReferenciaRDS();
ref.setCodigo(codigoRDS);
ref.setClave(documento.getClave());
return ref;
} catch (Exception e) {
throw new Exception(e);
} finally {
close(session);
}
}
开发者ID:GovernIB,项目名称:sistra,代码行数:21,代码来源:ResolveRDS.java
注:本文中的net.sf.hibernate.Session类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论