private void initTransients() { this.hashcode = new ValueHolder<Integer>( new ValueHolder.DeferredInitializer<Integer>() { @Override public Integer initialize() { return value == null ? 0 : type.getHashCode( value ); } } ); } }
@Override public int hashCode() { return hashcode.getValue(); } @Override
@Override public String toString() { return toString.getValue(); }
private void initTransients() { this.toString = new ValueHolder<>( new ValueHolder.DeferredInitializer<String>() { @Override public String initialize() { //Complex toString is needed as naturalIds for entities are not simply based on a single value like primary keys //the only same way to differentiate the keys is to included the disassembled values in the string. final StringBuilder toStringBuilder = new StringBuilder().append( entityName ).append( "##NaturalId[" ); for ( int i = 0; i < naturalIdValues.length; i++ ) { toStringBuilder.append( naturalIdValues[i] ); if ( i + 1 < naturalIdValues.length ) { toStringBuilder.append( ", " ); } } toStringBuilder.append( "]" ); return toStringBuilder.toString(); } } ); }
public LoadedConfig loadConfigXmlFile(File cfgXmlFile) { try { final JaxbCfgHibernateConfiguration jaxbCfg = jaxbProcessorHolder.getValue().unmarshal( new FileInputStream( cfgXmlFile ), new Origin( SourceType.FILE, cfgXmlFile.getAbsolutePath() ) ); return LoadedConfig.consume( jaxbCfg ); } catch (FileNotFoundException e) { throw new ConfigurationException( "Specified cfg.xml file [" + cfgXmlFile.getAbsolutePath() + "] does not exist" ); } }
private void initTransients() { this.hashcode = new ValueHolder<Integer>( new ValueHolder.DeferredInitializer<Integer>() { @Override public Integer initialize() { return value == null ? 0 : type.getJavaTypeDescriptor().extractHashCode( value ); } } ); } }
public LoadedConfig loadConfigXmlUrl(URL url) { try { final InputStream stream = url.openStream(); try { final JaxbCfgHibernateConfiguration jaxbCfg = jaxbProcessorHolder.getValue().unmarshal( stream, new Origin( SourceType.URL, url.toExternalForm() ) ); return LoadedConfig.consume( jaxbCfg ); } finally { try { stream.close(); } catch (IOException e) { log.debug( "Unable to close cfg.xml URL stream", e ); } } } catch (IOException e) { throw new ConfigurationException( "Could not access given cfg.xml URL input stream", e ); } }
private void initTransients() { this.toString = new ValueHolder<String>( new ValueHolder.DeferredInitializer<String>() { @Override public String initialize() { //Complex toString is needed as naturalIds for entities are not simply based on a single value like primary keys //the only same way to differentiate the keys is to included the disassembled values in the string. final StringBuilder toStringBuilder = new StringBuilder().append(entityName).append("##NaturalId["); for (int i = 0; i < naturalIdValues.length; i++) { toStringBuilder.append(naturalIdValues[i]); if (i + 1 < naturalIdValues.length) { toStringBuilder.append(", "); } } toStringBuilder.append("]"); return toStringBuilder.toString(); } } ); }
public LoadedConfig loadConfigXmlResource(String cfgXmlResourceName) { final InputStream stream = bootstrapServiceRegistry.getService( ClassLoaderService.class ).locateResourceStream( cfgXmlResourceName ); if ( stream == null ) { throw new ConfigurationException( "Could not locate cfg.xml resource [" + cfgXmlResourceName + "]" ); } try { final JaxbCfgHibernateConfiguration jaxbCfg = jaxbProcessorHolder.getValue().unmarshal( stream, new Origin( SourceType.RESOURCE, cfgXmlResourceName ) ); return LoadedConfig.consume( jaxbCfg ); } finally { try { stream.close(); } catch (IOException e) { log.debug( "Unable to close cfg.xml resource stream", e ); } } }
private void initTransients() { this.toString = new ValueHolder<String>( new ValueHolder.DeferredInitializer<String>() { @Override public String initialize() { //Complex toString is needed as naturalIds for entities are not simply based on a single value like primary keys //the only same way to differentiate the keys is to included the disassembled values in the string. final StringBuilder toStringBuilder = new StringBuilder().append(entityName).append("##NaturalId["); for (int i = 0; i < naturalIdValues.length; i++) { toStringBuilder.append(naturalIdValues[i]); if (i + 1 < naturalIdValues.length) { toStringBuilder.append(", "); } } toStringBuilder.append("]"); return toStringBuilder.toString(); } } ); }
protected JDBCException convertSqlException(String message, SQLException e) { // if JdbcServices#getSqlExceptionHelper is available, use it... final JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class ); if ( jdbcServices != null && jdbcServices.getSqlExceptionHelper() != null ) { return jdbcServices.getSqlExceptionHelper().convert( e, message, null ); } // likely we are still in the process of initializing the ServiceRegistry, so use the simplified // SQLException conversion return simpleConverterAccess.getValue().convert( e, message, null ); }
private void initTransients() { this.toString = new ValueHolder<String>( new ValueHolder.DeferredInitializer<String>() { @Override public String initialize() { //Complex toString is needed as naturalIds for entities are not simply based on a single value like primary keys //the only same way to differentiate the keys is to included the disassembled values in the string. final StringBuilder toStringBuilder = new StringBuilder().append(entityName).append("##NaturalId["); for (int i = 0; i < naturalIdValues.length; i++) { toStringBuilder.append(naturalIdValues[i]); if (i + 1 < naturalIdValues.length) { toStringBuilder.append(", "); } } toStringBuilder.append("]"); return toStringBuilder.toString(); } } ); }
@Override public String toString() { return toString.getValue(); }
private void initTransients() { this.toString = new ValueHolder<>( new ValueHolder.DeferredInitializer<String>() { @Override public String initialize() { //Complex toString is needed as naturalIds for entities are not simply based on a single value like primary keys //the only same way to differentiate the keys is to included the disassembled values in the string. final StringBuilder toStringBuilder = new StringBuilder().append( entityName ).append( "##NaturalId[" ); for ( int i = 0; i < naturalIdValues.length; i++ ) { toStringBuilder.append( naturalIdValues[i] ); if ( i + 1 < naturalIdValues.length ) { toStringBuilder.append( ", " ); } } toStringBuilder.append( "]" ); return toStringBuilder.toString(); } } ); }
@Override public String toString() { return toString.getValue(); }
@Override public String toString() { return toString.getValue(); }
@Override public int hashCode() { return hashcode.getValue(); }
@Override public String toString() { return toString.getValue(); }
public LoadedConfig loadConfigXmlFile(File cfgXmlFile) { try { final JaxbCfgHibernateConfiguration jaxbCfg = jaxbProcessorHolder.getValue().unmarshal( new FileInputStream( cfgXmlFile ), new Origin( SourceType.FILE, cfgXmlFile.getAbsolutePath() ) ); return LoadedConfig.consume( jaxbCfg ); } catch (FileNotFoundException e) { throw new ConfigurationException( "Specified cfg.xml file [" + cfgXmlFile.getAbsolutePath() + "] does not exist" ); } }
public LoadedConfig loadConfigXmlUrl(URL url) { try { final InputStream stream = url.openStream(); try { final JaxbCfgHibernateConfiguration jaxbCfg = jaxbProcessorHolder.getValue().unmarshal( stream, new Origin( SourceType.URL, url.toExternalForm() ) ); return LoadedConfig.consume( jaxbCfg ); } finally { try { stream.close(); } catch (IOException e) { log.debug( "Unable to close cfg.xml URL stream", e ); } } } catch (IOException e) { throw new ConfigurationException( "Could not access given cfg.xml URL input stream", e ); } }