hi there, I have the following in the classpath of my project:
Quote:
postgresql-8.3-604.jdbc3.jar
slf4j-simple-1.5.8.jar
hibernate3.jar
antlr-2.7.6.jar
commons-collections-3.1.jar
dom4j-1.6.1.jar
javassist-3.9.0.GA.jar
jta-1.1.jar
slf4j-api-1.5.8.jar
hibernate-commons-annotations.jar
hibernate-validator.jar
I have the following POJO
Code:
public class Flower {
private long id;
@Length(min=10,max=255)
private String name;
//getters and setters
}
my hibernate.cfg.xml file is
Quote:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost/flowers</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.connection.password">postgrespostgres</property>
<property name="hibernate.connection.pool_size">1</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.validator.autoregister_listeners">true</property>
<mapping resource="Flower.hbm.xml"/>
</session-factory>
</hibernate-configuration>
it's a simple CRUD project and the persistence works, but the validation doesn't trigger.
the following code doesn't generate any exception, which was supposed to generate because the length of name is less than 10, and the object is persisted inconsistently
Code:
...
Flower f = new Flower();
f.setName("");
session.save(f);
...
what I'm doing wrong here?