当前位置: 首页>>代码示例>>Java>>正文


Java Hibernate类代码示例

本文整理汇总了Java中org.hibernate.Hibernate的典型用法代码示例。如果您正苦于以下问题:Java Hibernate类的具体用法?Java Hibernate怎么用?Java Hibernate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Hibernate类属于org.hibernate包,在下文中一共展示了Hibernate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getComparisonInitialiserForStopEdit

import org.hibernate.Hibernate; //导入依赖的package包/类
@Override
protected ComparisonEntityInitialiser<ItemDefinition> getComparisonInitialiserForStopEdit()
{
	return new ComparisonEntityInitialiser<ItemDefinition>()
	{
		@Override
		public void preUnlink(ItemDefinition t)
		{
			// We suck the big one for misusing hibernate.
			initBundle(t.getName());
			initBundle(t.getDescription());
			t.getItemMetadataRules();
			Hibernate.initialize(t.getWorkflow());
		}
	};
}
 
开发者ID:equella,项目名称:Equella,代码行数:17,代码来源:ItemDefinitionServiceImpl.java

示例2: createBlob

import org.hibernate.Hibernate; //导入依赖的package包/类
/**
	 * Permet de créer un Blob à partir d'un stream sans indiquer/connaître la taille. Fonctionne uniquement avec jdbc4. Une exception est
	 * lancée si jdbc4 n'est pas présent.
	 * 
	 * @param aInputStream
	 * @return
	 */
	public Blob createBlob(InputStream aInputStream) {

		final LobCreator lobCreator = Hibernate.getLobCreator(session);
//		// JDBC4 -> pas besoin de la taille
//		if (lobCreator instanceof ContextualLobCreator) {
//			// Passage de -1 comme taille: De toutes façons cette valeur n'est pas utilisée en jdbc4
//			return lobCreator.createBlob(aInputStream, -1);
//		}
//		else {
			// Fallback JDBC3
			// On récupère le stream pour connaitre la taille
			final ByteArrayOutputStream bos = new ByteArrayOutputStream();
			try {
				IOUtils.copy(aInputStream, bos);
				return lobCreator.createBlob(new ByteArrayInputStream(bos.toByteArray()), bos.size());
			}
			catch (IOException ioe) {
				throw new RuntimeException(ioe);
			}
//		}
	}
 
开发者ID:shared-vd,项目名称:tipi-engine,代码行数:29,代码来源:BlobFactory.java

示例3: findBySSO

import org.hibernate.Hibernate; //导入依赖的package包/类
public AdmUser findBySSO(String email) {
    logger.info("email : {}", email);
    Criteria crit = createEntityCriteria();
    crit.add(Restrictions.eq("email", email));
    AdmUser user = (AdmUser) crit.uniqueResult();
    if (user != null) {
        Hibernate.initialize(user.getUserRoles());
    }
    return user;
}
 
开发者ID:mustafamym,项目名称:FeedbackCollectionAndMgmtSystem,代码行数:11,代码来源:UserDaoImpl.java

示例4: removeProduct

import org.hibernate.Hibernate; //导入依赖的package包/类
/**
 * Remove a product from a collection. The product should stay in the
 * database.
 *
 * @param cid the collection id where remove product.
 * @param pid the product id to remove.
 * @param user unused parameter.
 */
public void removeProduct (final String cid, final Long pid, User user)
{
   Collection collection = read(cid);
   if (collection == null)
   {
      LOGGER.warn("Unknown collection #" + cid);
      return;
   }
   Product product = productDao.read(pid);
   if (product == null)
   {
      LOGGER.warn("Unknown product #" + pid);
      return;
   }

   Hibernate.initialize (collection.getProducts());
   collection.getProducts().remove(product);
   update(collection);

   fireProductRemoved (new DaoEvent<> (collection), product);
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:30,代码来源:CollectionDao.java

示例5: delete

import org.hibernate.Hibernate; //导入依赖的package包/类
@Override
public void delete ()
{
   Long id = 1L;
   FileScanner element = dao.read (id);
   Set<Collection> collections = element.getCollections ();
   Hibernate.initialize (collections);
   dao.delete (element);

   assertEquals (dao.count (), (howMany () - 1));
   assertNull (dao.read (id));
   for (Collection collection : collections)
   {
      assertNotNull (cdao.read (collection.getUUID ()));
   }
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:17,代码来源:TestFileScannerDao.java

示例6: delete

import org.hibernate.Hibernate; //导入依赖的package包/类
@Override
@Test (dependsOnMethods = { "read", "create" })
public void delete ()
{
   long id = 1;
   Eviction eviction = dao.read (id);
   Set<Product> ps = eviction.getProducts ();
   Hibernate.initialize (ps);

   dao.delete (eviction);
   assertEquals (dao.count (), (howMany () - 1));
   assertNull (dao.read (id));
   for (Product p : ps)
   {
      assertNotNull (pdao.read (p.getId ()));
   }
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:18,代码来源:TestEvictionDao.java

示例7: unproxyEntity

import org.hibernate.Hibernate; //导入依赖的package包/类
protected <T> T unproxyEntity(T template) {
    if (template instanceof HibernateProxy) {
        Hibernate.initialize(template);
        template = (T) ((HibernateProxy) template)
                .getHibernateLazyInitializer()
                .getImplementation();
    }
    return template;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:10,代码来源:EJBTestBase.java

示例8: getById

import org.hibernate.Hibernate; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public T getById(Long pk) throws SQLException {
	Session session = HibernateUtil.getSessionFactory().openSession();
	T entity = null;

	try {
		session.beginTransaction();
		entity = (T) session.get(getEntityClass(), pk);
		Hibernate.initialize(entity);
		session.getTransaction().commit();

	} catch (HibernateException hibernateException) {
		session.getTransaction().rollback();

		throw new SQLException(hibernateException);

	} finally {
		session.close();
	}

	return entity;
}
 
开发者ID:mrh3nry,项目名称:Celebino,代码行数:23,代码来源:GenericDao.java

示例9: nullSafeGet

import org.hibernate.Hibernate; //导入依赖的package包/类
@Override
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws SQLException
{
	String dbValue = Hibernate.STRING.nullSafeGet(rs, names[0]);
	if( dbValue != null )
	{
		return unescape(dbValue);
	}
	else
	{
		return null;
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:14,代码来源:HibernateEscapedString.java

示例10: createMappings

import org.hibernate.Hibernate; //导入依赖的package包/类
private EntryCache createMappings(List<MimeEntry> entries)
{
	Map<String, MimeEntry> mappedEntries = new HashMap<String, MimeEntry>();
	Map<String, MimeEntry> mimeEntries = new HashMap<String, MimeEntry>();
	for( MimeEntry mimeEntry : entries )
	{
		Collection<String> extensions = mimeEntry.getExtensions();
		// Load it all up
		Hibernate.initialize(mimeEntry.getAttributes());
		for( String ext : extensions )
		{
			mappedEntries.put(ext, mimeEntry);
		}
		mimeEntries.put(mimeEntry.getType(), mimeEntry);
	}
	return new EntryCache(mappedEntries, mimeEntries);
}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:MimeTypeServiceImpl.java

示例11: reassociateIfUninitializedProxy

import org.hibernate.Hibernate; //导入依赖的package包/类
@Override
public boolean reassociateIfUninitializedProxy(Object value) throws MappingException {
	if ( value instanceof ElementWrapper ) {
		value = ( (ElementWrapper) value ).getElement();
	}

	if ( !Hibernate.isInitialized( value ) ) {
		final HibernateProxy proxy = (HibernateProxy) value;
		final LazyInitializer li = proxy.getHibernateLazyInitializer();
		reassociateProxy( li, proxy );
		return true;
	}
	else {
		return false;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:StatefulPersistenceContext.java

示例12: set

import org.hibernate.Hibernate; //导入依赖的package包/类
protected void set(PreparedStatement st, Object value, int index, SessionImplementor session) throws SQLException {
	if ( value == null ) {
		st.setNull( index, sqlTypes( null )[0] );
	}
	else {
		byte[] toSet = unWrap( value );
		final boolean useInputStream = session.getFactory().getDialect().useInputStreamToInsertBlob();

		if ( useInputStream ) {
			st.setBinaryStream( index, new ByteArrayInputStream( toSet ), toSet.length );
		}
		else {
			st.setBlob( index, Hibernate.getLobCreator( session ).createBlob( toSet ) );
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:ByteArrayBlobType.java

示例13: getOptions

import org.hibernate.Hibernate; //导入依赖的package包/类
private WrapperOptions getOptions(final SessionImplementor session) {
	return new WrapperOptions() {
		public boolean useStreamForLobBinding() {
			return Environment.useStreamsForBinary()
					|| session.getFactory().getDialect().useInputStreamToInsertBlob();
		}

		public LobCreator getLobCreator() {
			return Hibernate.getLobCreator( session );
		}

		public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
			final SqlTypeDescriptor remapped = sqlTypeDescriptor.canBeRemapped()
					? session.getFactory().getDialect().remapSqlTypeDescriptor( sqlTypeDescriptor )
					: sqlTypeDescriptor;
			return remapped == null ? sqlTypeDescriptor : remapped;
		}
	};
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:AbstractStandardBasicType.java

示例14: createEcrfFieldStatusEntryDetachedCriteriaMaxId

import org.hibernate.Hibernate; //导入依赖的package包/类
private static DetachedCriteria createEcrfFieldStatusEntryDetachedCriteriaMaxId(org.hibernate.Criteria ecrfFieldStatusEntryCriteria, org.hibernate.Criteria ecrfFieldCriteria,
		org.hibernate.Criteria probandListEntryCriteria,
		ECRFFieldStatusQueue queue, Long probandListEntryId, Long ecrfFieldId) {
	DetachedCriteria subQuery = createEcrfFieldStatusEntryDetachedCriteria(ecrfFieldStatusEntryCriteria, ecrfFieldCriteria, probandListEntryCriteria, probandListEntryId,
			ecrfFieldId);
	if (queue != null) {
		subQuery.add(Restrictions.eq("queue", queue));
		subQuery.setProjection(Projections.max("id"));
	} else {
		ProjectionList proj = Projections.projectionList();
		proj.add(Projections.sqlGroupProjection(
				"max({alias}.id) as maxId",
				"{alias}.queue",
				new String[] { "maxId" },
				new org.hibernate.type.Type[] { Hibernate.LONG }));
		subQuery.setProjection(proj);
	}

	return subQuery;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:21,代码来源:ECRFFieldStatusEntryDaoImpl.java

示例15: getHomeMunicipalityName

import org.hibernate.Hibernate; //导入依赖的package包/类
@Nonnull
public LocalisedString getHomeMunicipalityName() {
    if (this.homeMunicipality != null) {
        if (!Hibernate.isInitialized(this.homeMunicipality)) {
            try {
                // Referenced row might not exist
                return this.homeMunicipality.getNameLocalisation();
            } catch (UnresolvableObjectException | EntityNotFoundException o) {
                this.homeMunicipality = null;
            }
        } else {
            return this.homeMunicipality.getNameLocalisation();
        }
    }
    return LocalisedString.EMPTY;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:17,代码来源:Person.java


注:本文中的org.hibernate.Hibernate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。