本文整理汇总了Java中org.hibernate.engine.spi.SharedSessionContractImplementor类的典型用法代码示例。如果您正苦于以下问题:Java SharedSessionContractImplementor类的具体用法?Java SharedSessionContractImplementor怎么用?Java SharedSessionContractImplementor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SharedSessionContractImplementor类属于org.hibernate.engine.spi包,在下文中一共展示了SharedSessionContractImplementor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: nullSafeGet
import org.hibernate.engine.spi.SharedSessionContractImplementor; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner)
throws HibernateException, SQLException
{
final String cellContent = rs.getString(names[0]);
if (cellContent == null)
throw new RuntimeException("cell Content is null");
final ObjectMapper mapper = SpringContext.getBean(ObjectMapper.class);
try
{
return mapper.readValue(cellContent, returnedClass());
} catch (final IOException ex)
{
throw new RuntimeException("Failed to convert String to Invoice: " + ex.getMessage(), ex);
}
}
示例2: nullSafeSet
import org.hibernate.engine.spi.SharedSessionContractImplementor; //导入依赖的package包/类
@Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session)
throws HibernateException, SQLException
{
if (value == null)
{
st.setNull(index, Types.VARCHAR);
return;
}
try
{
final ObjectMapper mapper = new ObjectMapper();
final StringWriter w = new StringWriter();
mapper.writeValue(w, value);
w.flush();
st.setObject(index, w.toString(), Types.VARCHAR);
} catch (final Exception ex)
{
throw new RuntimeException("Failed to convert Invoice to String: " + ex.getMessage(), ex);
}
}
示例3: nullSafeGet
import org.hibernate.engine.spi.SharedSessionContractImplementor; //导入依赖的package包/类
@Override
public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner)
throws HibernateException, SQLException {
Array array = rs.getArray(names[0]);
if (array == null) {
return null;
}
Long[] javaArray = (Long[]) array.getArray();
ArrayList<Long> result = new ArrayList<>();
Collections.addAll(result, javaArray); //do not use Arrays.asList(), that method returns a fake ArrayList
return result;
}
示例4: nullSafeSet
import org.hibernate.engine.spi.SharedSessionContractImplementor; //导入依赖的package包/类
@Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session)
throws HibernateException, SQLException {
Connection connection = st.getConnection();
if (value == null) {
st.setNull(index, sqlTypes()[0]);
} else {
@SuppressWarnings("unchecked") ArrayList<Long> castObject = (ArrayList) value;
Long[] longs = castObject.toArray(new Long[castObject.size()]);
Array array = connection.createArrayOf("bigint", longs);
st.setArray(index, array);
}
}
示例5: nullSafeGet
import org.hibernate.engine.spi.SharedSessionContractImplementor; //导入依赖的package包/类
@Override
public Object nullSafeGet(ResultSet rs,
String[] names,
SharedSessionContractImplementor session,
Object owner) throws HibernateException, SQLException {
String detailRaw = rs.getString(names[0]);
if (detailRaw == null) {
return null;
}
// according to credential.hbm.xml property sequence
String typeRaw = rs.getString(2);
CredentialType type = CredentialType.valueOf(typeRaw);
return GSON.fromJson(detailRaw, type.getClazz());
}
示例6: nullSafeSet
import org.hibernate.engine.spi.SharedSessionContractImplementor; //导入依赖的package包/类
@Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session)
throws HibernateException, SQLException {
// set to null
if (value == null) {
st.setBytes(index, null);
return;
}
// value already in string type
if (value instanceof byte[]) {
st.setBytes(index, (byte[]) value);
return;
}
byte[] bytes = stringToByte((String) value);
st.setBytes(index, bytes);
}
示例7: nullSafeSet
import org.hibernate.engine.spi.SharedSessionContractImplementor; //导入依赖的package包/类
/**
* @param st
* @param value
* @param index
* @param session
* @throws HibernateException
* @throws SQLException
*/
@Override
public void nullSafeSet(PreparedStatement st,
Object value,
int index,
SharedSessionContractImplementor session) throws HibernateException, SQLException {
// set to null
if (value == null) {
st.setString(index, null);
return;
}
// value already in string type
if (value instanceof String) {
st.setString(index, (String) value);
return;
}
String str = objectToJson(value);
st.setString(index, str);
}
示例8: cleanUpRows
import org.hibernate.engine.spi.SharedSessionContractImplementor; //导入依赖的package包/类
private void cleanUpRows(SharedSessionContractImplementor session, Queryable persister) {
final String sql = "delete from " + fullyQualifiedTableName + " where " + discriminatorColumn + "=?";
PreparedStatement ps = null;
try {
ps = session.getJdbcCoordinator().getStatementPreparer().prepareStatement(sql, false);
ps.setString(1, generateDiscriminatorValue(persister));
StringType.INSTANCE.set(ps, generateDiscriminatorValue(persister), 1, session);
session.getJdbcCoordinator().getResultSetReturn().executeUpdate(ps);
} catch (SQLException e) {
throw session.getJdbcServices().getSqlExceptionHelper().convert(e, "Unable to clean up id table [" + fullyQualifiedTableName + "]", sql);
} finally {
if (ps != null) {
session.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release(ps);
}
}
}
开发者ID:grimsa,项目名称:hibernate-single-table-bulk-id-strategy,代码行数:17,代码来源:SingleGlobalTemporaryTableBulkIdStrategy.java
示例9: nullSafeSet
import org.hibernate.engine.spi.SharedSessionContractImplementor; //导入依赖的package包/类
@Override
public void nullSafeSet( PreparedStatement ps, Object value, int idx, SharedSessionContractImplementor session )
throws HibernateException,
SQLException
{
if ( value == null )
{
ps.setObject( idx, null );
return;
}
PGobject pg = new PGobject();
pg.setType( "jsonb" );
pg.setValue( convertObjectToJson( value ) );
ps.setObject( idx, pg );
}
示例10: nullSafeGet
import org.hibernate.engine.spi.SharedSessionContractImplementor; //导入依赖的package包/类
@Override
public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException {
Reader reader = rs.getCharacterStream( names[0] );
if ( reader == null ) return null;
StringBuilder result = new StringBuilder( 4096 );
try {
char[] charbuf = new char[4096];
for ( int i = reader.read( charbuf ); i > 0 ; i = reader.read( charbuf ) ) {
result.append( charbuf, 0, i );
}
}
catch (IOException e) {
throw new SQLException( e.getMessage() );
}
return result.toString();
}
示例11: nullSafeGet
import org.hibernate.engine.spi.SharedSessionContractImplementor; //导入依赖的package包/类
@Override
public Object nullSafeGet(ResultSet rs, String[] names,
SharedSessionContractImplementor session, Object owner)
throws HibernateException, SQLException
{
String name = rs.getString(names[0]);
if (rs.wasNull()) {
return null;
}
for (PersistentEnum value : returnedClass().getEnumConstants()) {
if (name.equals(value.getId())) {
return value;
}
}
throw new IllegalStateException(
"Unknown " + returnedClass().getSimpleName() + " value [" + name + "]");
}
示例12: nullSafeGet
import org.hibernate.engine.spi.SharedSessionContractImplementor; //导入依赖的package包/类
@Override
public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner)
throws HibernateException, SQLException {
byte[] bytes = rs.getBytes(names[0]);
if (rs.wasNull()) {
return null;
} else {
BitSet bits = new BitSet(bytes.length);
int index = 0;
for (byte b : bytes) {
// 1 and 0 are encoded as ascii values of '1' and '0'
bits.set(index++, b - '0' != 0);
}
return bits;
}
}
示例13: get
import org.hibernate.engine.spi.SharedSessionContractImplementor; //导入依赖的package包/类
/**
* Returns <code>null</code> if the item is not readable. Locked items are not readable, nor are items created
* afterQuery the start of this transaction.
*/
public final Object get(SharedSessionContractImplementor session, Object key, long txTimestamp) throws CacheException {
readLockIfNeeded(key);
try {
final Lockable item = (Lockable) region().get(key);
final boolean readable = item != null && item.isReadable(txTimestamp);
if (readable) {
return item.getValue();
} else {
return null;
}
} finally {
readUnlockIfNeeded(key);
}
}
开发者ID:mihaicostin,项目名称:hibernate-l2-memcached,代码行数:20,代码来源:AbstractReadWriteMemcachedAccessStrategy.java
示例14: putFromLoad
import org.hibernate.engine.spi.SharedSessionContractImplementor; //导入依赖的package包/类
/**
* Returns <code>false</code> and fails to put the value if there is an existing un-writeable item mapped to this
* key.
*/
@Override
public final boolean putFromLoad(
SharedSessionContractImplementor session,
Object key,
Object value,
long txTimestamp,
Object version,
boolean minimalPutOverride)
throws CacheException {
region.getCache().lock(key);
try {
final Lockable item = (Lockable) region().get(key);
final boolean writeable = item == null || item.isWriteable(txTimestamp, version, versionComparator);
if (writeable) {
region().put(key, new Item(value, version, region.nextTimestamp()));
return true;
} else {
return false;
}
} finally {
region.getCache().unlock(key);
}
}
开发者ID:mihaicostin,项目名称:hibernate-l2-memcached,代码行数:29,代码来源:AbstractReadWriteMemcachedAccessStrategy.java
示例15: putFromLoad
import org.hibernate.engine.spi.SharedSessionContractImplementor; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public boolean putFromLoad(
SharedSessionContractImplementor session,
Object key,
Object value,
long txTimestamp,
Object version,
boolean minimalPutOverride) throws CacheException {
if (minimalPutOverride && cache.get(key) != null) {
return false;
}
//OptimisticCache? versioning?
cache.put(key, value);
return true;
}
开发者ID:mihaicostin,项目名称:hibernate-l2-memcached,代码行数:19,代码来源:TransactionalMemcachedEntityRegionAccessStrategy.java