 
                                        
                                
                         
                        
                                
                                
                                        
                                                
                                        
                                        
                                        [Hibernate-JIRA] Created: (BVAL-198) Simplify creation of ConstraintViolationExceptions
                                
                                
                                
                                    
                                        by Gunnar Morling (JIRA)
                                    
                                
                                
                                        Simplify creation of ConstraintViolationExceptions
--------------------------------------------------
                 Key: BVAL-198
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/BVAL-198
             Project: Bean Validation
          Issue Type: Improvement
          Components: spec-general
    Affects Versions: 1.1
            Reporter: Gunnar Morling
javax.validation.ConstraintViolationException wraps a set of constraint violations, currently in the following form:
Set<ConstraintViolation<?>> constraintViolations
As the exception's constructors have a parameter of the same type, instantiating it is not as easy as expected:
Validator validator = ...;
DomainObject domainObject = new DomainObject();
Set<ConstraintViolation<DomainObject>> constraintViolations = validator.validate(domainObject);
//compiler error: ("The constructor ConstraintViolationException(Set<ConstraintViolation<DomainObject>>) is undefined")
throw new ConstraintViolationException(constraintViolations);
//this works
throw new ConstraintViolationException(new HashSet<ConstraintViolation<?>>(constraintViolations));
This problem can be solved by changing the collection type to 
Set<? extends ConstraintViolation<?>>
The exception then would read as follows:
public class ConstraintViolationException extends ValidationException {
	private final Set<? extends ConstraintViolation<?>> constraintViolations;
	public ConstraintViolationException(String message, Set<? extends ConstraintViolation<?>> constraintViolations) {
		super( message );
		this.constraintViolations = constraintViolations;
	}
	public ConstraintViolationException(Set<? extends ConstraintViolation<?>> constraintViolations) {
		super();
		this.constraintViolations = constraintViolations;
	}
	public Set<ConstraintViolation<?>> getConstraintViolations() {
		return new HashSet<ConstraintViolation<?>>(constraintViolations);
	}
}
This makes the exception easier to use for producers, while maintaining simplicity for clients (since getConstraintViolations() still returns a Set<ConstraintViolation<?>>, clients don't have to do deal with the bound wildcard expression).
-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
        
                                
                         
                        
                                
                                12 years, 11 months
                        
                        
                 
         
 
        
            
        
        
        
            
        
        
        
            
        
        
        
            
        
        
        
                
                        
                                
                                 
                                        
                                
                         
                        
                                
                                
                                        
                                                
                                        
                                        
                                        [Hibernate-JIRA] Created: (HHH-6127) Wrong save or read unicode value on @Lob String field in PostgreSQL 8.4
                                
                                
                                
                                    
                                        by Mihail Slobodyanuk (JIRA)
                                    
                                
                                
                                        Wrong save or read unicode value on @Lob String field in PostgreSQL 8.4
-----------------------------------------------------------------------
                 Key: HHH-6127
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6127
             Project: Hibernate Core
          Issue Type: Bug
    Affects Versions: 3.6.3
         Environment: PostgreSQL 8.4.5 on Ubuntu 32, Hibernate 3.6.0 - 3.6.3, jdbc driver: postgresql-8.3-603.jdbc3 
            Reporter: Mihail Slobodyanuk
            Priority: Critical
<hibernate-configuration>
  <session-factory>
    <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
    <property name="hibernate.connection.url">jdbc:postgresql://localhost/test</property>
    <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
    <property name="hibernate.connection.username">postgres</property>
    <property name="hibernate.connection.password">postgres</property>
    <property name="hbm2ddl.auto">update</property>
    <property name="hibernate.connection.charSet">UTF-8</property>
    <property name="hibernate.show_sql">true</property>
    <property name="hibernate.current_session_context_class">thread</property>
  </session-factory>
</hibernate-configuration>
@Entity
public class ReportTemplate{
    @Id
    @GeneratedValue
    private Integer id;
    @Lob
    private String body;
...
}
At save (or at read) operation with 'body' field value is broken. In DB stored Blob's OID.
The next code throw AssertionError:
String str="Русский текст";//Unicode string
rt = new ReportTemplate();
rt.setBody(str); 
Serializable id = hsm.getSession().save(rt);
hsm.commit();
hsm.getSession().clear();
rt = (ReportTemplate) hsm.getSession().get(ReportTemplate.class, id);
assert str.equals(rt.getBody());
-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
       
                                
                         
                        
                                
                                12 years, 11 months