List of usage examples for org.hibernate HibernateException HibernateException
public HibernateException(Throwable cause)
From source file:com.enonic.cms.store.hibernate.type.LazyInitializedJDOMDocumentUserType.java
License:Open Source License
private byte[] convertToBytes(LazyInitializedJDOMDocument value) { if (value == null) { return null; }/*from w ww . j a v a 2s .co m*/ try { String text = value.getDocumentAsString(); return text != null ? text.getBytes("UTF-8") : null; } catch (UnsupportedEncodingException e) { throw new HibernateException(e); } }
From source file:com.enonic.cms.store.hibernate.type.LazyInitializedJDOMDocumentUserType.java
License:Open Source License
private LazyInitializedJDOMDocument convertFromBytes(byte[] bytes) { try {// w w w . j a va2 s .c o m if (bytes == null) { return null; } if (bytes.length == 0) { return null; } return new LazyInitializedJDOMDocument(new String(bytes, "UTF-8")); } catch (Exception e) { throw new HibernateException(e); } }
From source file:com.enonic.cms.store.hibernate.type.XMLBytesUserType.java
License:Open Source License
private byte[] convertToBinaryFormat(XMLBytes value) throws HibernateException { try {//from w w w. j a va 2 s . c o m if (value != null) { return value.getAsString().getBytes("UTF-8"); } else { return null; } } catch (UnsupportedEncodingException e) { throw new HibernateException(e); } }
From source file:com.enonic.cms.store.hibernate.type.XMLBytesUserType.java
License:Open Source License
private XMLBytes convertFromBinaryFormat(byte[] xmlAsBytes) throws HibernateException { try {//from w w w.ja v a 2 s . c o m if (xmlAsBytes == null) { return null; } if (xmlAsBytes.length == 0) { return null; } final String xmlAsString = new String(xmlAsBytes, "UTF-8"); final XMLBytes xmlBytes = XMLDocumentParser.getInstance().parseDocument(xmlAsString); //test(); return xmlBytes; } catch (UnsupportedEncodingException e) { throw new HibernateException(e); } }
From source file:com.enonic.cms.store.hibernate.type.XmlStringUserType.java
License:Open Source License
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException { String data;/* w ww . jav a 2 s. c o m*/ byte[] bytes = BinaryColumnReader.readBinary(names[0], rs); if (bytes == null) { data = null; } else { try { data = new String(bytes, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new HibernateException(e); } } return data; }
From source file:com.enonic.cms.store.hibernate.type.XmlStringUserType.java
License:Open Source License
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException { if (value == null) { st.setNull(index, getSqlType()); } else {/* w ww . j ava 2s. c o m*/ String s = (String) value; try { st.setBytes(index, s.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new HibernateException(e); } } }
From source file:com.ephesoft.dcma.core.hibernate.EphesoftCriteria.java
License:Open Source License
/** * To create alias.// w w w .java2 s .c o m * * @param associationPath String * @param containsProperty boolean * @return DetachedCriteria * @throws HibernateException in case of error */ public DetachedCriteria createAlias(String associationPath, boolean containsProperty) throws HibernateException { String[] associations = split(associationPath); if (associations.length < (containsProperty ? 2 : 1)) { throw new HibernateException("Incorrect Association Path..."); } for (int i = 0; i < (containsProperty ? associations.length - 1 : associations.length); i++) { if (getAlias(associations[i]) == null) { this.createAlias(associations[i], associations[i]); } } return this; }
From source file:com.ephesoft.dcma.core.hibernate.EphesoftCriteria.java
License:Open Source License
/** * To get alias.//from ww w . j a v a 2 s . c o m * * @param associationPath String * @param containsProperty boolean * @return String */ public String getAlias(String associationPath, boolean containsProperty) { String path = null; String[] involvedEntitiyVars = split(associationPath); if (involvedEntitiyVars.length == 1) { path = involvedEntitiyVars[0]; } else { if (involvedEntitiyVars.length < (containsProperty ? 2 : 1)) { throw new HibernateException("Incorrect Association Path..."); } String alias = (String) this.aliasEntityMap .getKey(involvedEntitiyVars[involvedEntitiyVars.length - (containsProperty ? 2 : 1)]); if (alias != null && containsProperty) { path = alias + CoreConstants.DOT + involvedEntitiyVars[involvedEntitiyVars.length - 1]; } } return path; }
From source file:com.evolveum.midpoint.repo.sql.util.CertWorkItemIdGenerator.java
License:Apache License
@Override public Serializable generate(SharedSessionContractImplementor session, Object object) throws HibernateException { if (object instanceof RAccessCertificationWorkItem) { return generate((RAccessCertificationWorkItem) object); } else {/*from w w w.j a v a 2s .c om*/ throw new HibernateException("Couldn't create id for '" + object.getClass().getSimpleName() + "' not instance of '" + RAccessCertificationWorkItem.class.getName() + "'."); } }
From source file:com.evolveum.midpoint.repo.sql.util.ContainerIdGenerator.java
License:Apache License
@Override public Serializable generate(SessionImplementor session, Object object) throws HibernateException { if (!(object instanceof Container)) { throw new HibernateException("Couldn't create id for '" + object.getClass().getSimpleName() + "' not instance of RContainer."); }//from www .j av a2 s. c om return generate((Container) object); }