Hello,
First of all my Versions I'm using:
Hibernate: 3.6.0.Beta2
HibernateAnnotations: 3.4.0.GA
HibernateValidator: 4.0.2.GA
Spring: 3.0.0.RELEASE
Postgres: 8.4-701.jdbc4
I'm playing around with Hibernate Validator and i encountered a problem while trying to generate schema constraints from validator annotations. I have the following Object to be validated:
Code:
@Entity
public class Abteilung extends AbstractPojo {
@NotNull
@Length(max = 10)
private String bezeichnung;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
[...getter and setter ommitted]
In my spring context which handles all hibernate objects (hibernate itself works fine by the way) i set the option to generate ddl constraints like that:
Code:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>vereinsverwaltung.core.pojo.Abteilung</value>
[...other mappings ommitted]
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
hibernate.hbm2ddl.auto=create
[b]javax.persistence.validation.mode=ddl[/b]
</value>
</property>
</bean>
When I now start my Application i can see the create logs in my console. But when i take a look in the database I cannot find any constraints:
Code:
CREATE TABLE abteilung
(
id integer NOT NULL,
bezeichnung character varying(255),
CONSTRAINT abteilung_pkey PRIMARY KEY (id)
)
WITH (OIDS=FALSE);
Am I doing anything wrong?
Thank you for helping in advance,
Yours,
Mitschi