org.hibernate.cfg.Environment.useStreamsForBinary()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(103)

本文整理了Java中org.hibernate.cfg.Environment.useStreamsForBinary()方法的一些代码示例,展示了Environment.useStreamsForBinary()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Environment.useStreamsForBinary()方法的具体详情如下:
包路径:org.hibernate.cfg.Environment
类名称:Environment
方法名:useStreamsForBinary

Environment.useStreamsForBinary介绍

[英]Should we use streams to bind binary types to JDBC IN parameters?
[中]我们应该在参数中使用streams将二进制类型绑定到JDBC吗?

代码示例

代码示例来源:origin: hibernate/hibernate-orm

  1. @Override
  2. public boolean useStreamForLobBinding() {
  3. if ( useStreamForLobBinding == null ) {
  4. useStreamForLobBinding = Environment.useStreamsForBinary()
  5. || getJdbcServices().getJdbcEnvironment().getDialect().useInputStreamToInsertBlob();
  6. }
  7. return useStreamForLobBinding;
  8. }

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

  1. public boolean useStreamForLobBinding() {
  2. return Environment.useStreamsForBinary();
  3. }

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

  1. public boolean useStreamForLobBinding() {
  2. return Environment.useStreamsForBinary();
  3. }

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

  1. public boolean useStreamForLobBinding() {
  2. return Environment.useStreamsForBinary();
  3. }

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

  1. public boolean useStreamForLobBinding() {
  2. return Environment.useStreamsForBinary();
  3. }

代码示例来源:origin: hibernate/hibernate

  1. public void set(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
  2. if ( Environment.useStreamsForBinary() ) {
  3. st.setBinaryStream( index, new ByteArrayInputStream( (byte[]) value ), ( (byte[]) value ).length );
  4. }
  5. else {
  6. st.setBytes( index, (byte[]) value );
  7. }
  8. }

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

  1. public void set(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
  2. byte[] internalValue = toInternalFormat( value );
  3. if ( Environment.useStreamsForBinary() ) {
  4. st.setBinaryStream( index, new ByteArrayInputStream( internalValue ), internalValue.length );
  5. }
  6. else {
  7. st.setBytes( index, internalValue );
  8. }
  9. }

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

  1. public void set(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
  2. byte[] internalValue = toInternalFormat( value );
  3. if ( Environment.useStreamsForBinary() ) {
  4. st.setBinaryStream( index, new ByteArrayInputStream( internalValue ), internalValue.length );
  5. }
  6. else {
  7. st.setBytes( index, internalValue );
  8. }
  9. }

代码示例来源:origin: hibernate/hibernate

  1. public Object get(ResultSet rs, String name) throws HibernateException, SQLException {
  2. if ( Environment.useStreamsForBinary() ) {
  3. InputStream inputStream = rs.getBinaryStream(name);
  4. if (inputStream==null) return null; // is this really necessary?
  5. ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048);
  6. byte[] buffer = new byte[2048];
  7. try {
  8. while (true) {
  9. int amountRead = inputStream.read(buffer);
  10. if (amountRead == -1) {
  11. break;
  12. }
  13. outputStream.write(buffer, 0, amountRead);
  14. }
  15. inputStream.close();
  16. outputStream.close();
  17. }
  18. catch (IOException ioe) {
  19. throw new HibernateException( "IOException occurred reading a binary value", ioe );
  20. }
  21. return outputStream.toByteArray();
  22. }
  23. else {
  24. return rs.getBytes(name);
  25. }
  26. }

代码示例来源:origin: org.jasypt/jasypt-hibernate4

  1. public void nullSafeSet(final PreparedStatement st, final Object value, final int index,
  2. final SessionImplementor session)
  3. throws HibernateException, SQLException {
  4. checkInitialization();
  5. if (value == null) {
  6. st.setNull(index, sqlType);
  7. } else {
  8. final byte[] encryptedValue = this.encryptor.encrypt((byte[]) value);
  9. if (Environment.useStreamsForBinary()) {
  10. st.setBinaryStream(
  11. index,
  12. new ByteArrayInputStream(encryptedValue),
  13. encryptedValue.length);
  14. } else {
  15. st.setBytes(index, encryptedValue);
  16. }
  17. }
  18. }

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

  1. public Object get(ResultSet rs, String name) throws HibernateException, SQLException {
  2. if ( Environment.useStreamsForBinary() ) {
  3. InputStream inputStream = rs.getBinaryStream(name);
  4. if (inputStream==null) return toExternalFormat( null ); // is this really necessary?
  5. ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048);
  6. byte[] buffer = new byte[2048];
  7. try {
  8. while (true) {
  9. int amountRead = inputStream.read(buffer);
  10. if (amountRead == -1) {
  11. break;
  12. }
  13. outputStream.write(buffer, 0, amountRead);
  14. }
  15. inputStream.close();
  16. outputStream.close();
  17. }
  18. catch (IOException ioe) {
  19. throw new HibernateException( "IOException occurred reading a binary value", ioe );
  20. }
  21. return toExternalFormat( outputStream.toByteArray() );
  22. }
  23. else {
  24. return toExternalFormat( rs.getBytes(name) );
  25. }
  26. }

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

  1. public Object get(ResultSet rs, String name) throws HibernateException, SQLException {
  2. if ( Environment.useStreamsForBinary() ) {
  3. InputStream inputStream = rs.getBinaryStream(name);
  4. if (inputStream==null) return toExternalFormat( null ); // is this really necessary?
  5. ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048);
  6. byte[] buffer = new byte[2048];
  7. try {
  8. while (true) {
  9. int amountRead = inputStream.read(buffer);
  10. if (amountRead == -1) {
  11. break;
  12. }
  13. outputStream.write(buffer, 0, amountRead);
  14. }
  15. inputStream.close();
  16. outputStream.close();
  17. }
  18. catch (IOException ioe) {
  19. throw new HibernateException( "IOException occurred reading a binary value", ioe );
  20. }
  21. return toExternalFormat( outputStream.toByteArray() );
  22. }
  23. else {
  24. return toExternalFormat( rs.getBytes(name) );
  25. }
  26. }

代码示例来源:origin: org.jasypt/jasypt-hibernate4

  1. if (Environment.useStreamsForBinary()) {

代码示例来源:origin: org.hibernate.orm/hibernate-core

  1. @Override
  2. public boolean useStreamForLobBinding() {
  3. if ( useStreamForLobBinding == null ) {
  4. useStreamForLobBinding = Environment.useStreamsForBinary()
  5. || getJdbcServices().getJdbcEnvironment().getDialect().useInputStreamToInsertBlob();
  6. }
  7. return useStreamForLobBinding;
  8. }

代码示例来源:origin: org.hibernate.orm/hibernate-core

  1. if ( Environment.useStreamsForBinary() ) {
  2. typeContributions.contributeSqlTypeDescriptor( BlobSqlDescriptor.STREAM_BINDING );
  3. typeContributions.contributeSqlTypeDescriptor( ClobSqlDescriptor.STREAM_BINDING );

相关文章