-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: kann Validator @NotNull nicht deaktivieren
PostPosted: Wed Jun 13, 2007 8:53 am 
Newbie

Joined: Wed Jun 13, 2007 8:07 am
Posts: 1
Hi,

wir verwenden das Hibernate Validation Framework (3.0.0 GA).
Laut Dokumentation(Kapitel 2.2.1) kann man die Validierung auf dem Persistance Layer deaktivieren durch hibernate.validator.autoregister_listeners = false.
Es findet aber weiterhin eine Validierung statt allerdings ausschließlich für die @NotNull Annotation

...

import org.hibernate.validator.NotNull;

...

@Column(name="fax")
@NotNull
@PhoneNumber
public String getFax() {
return _fax;
}

...

Im folgenden ist der Stacktrace der Exception, die geworfen wird wenn als Junit test eine Instanz der annotierten Klasse gespeichert werden soll.

Weiß jemand, warum diese Validierung trotz Deaktivierung durchgeführt wird und wie ich das evtl. doch abschalten könnte?


org.springframework.dao.DataIntegrityViolationException: not-null property references a null or transient value: com.freiheit.extranet.partner.model.DBPerson.fax; nested exception is org.hibernate.PropertyValueException: not-null property references a null or transient value: com.freiheit.extranet.partner.model.DBPerson.fax
Caused by:
org.hibernate.PropertyValueException: not-null property references a null or transient value: com.freiheit.extranet.partner.model.DBPerson.fax
at org.hibernate.engine.Nullability.checkNullability(Nullability.java:72)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:290)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:121)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
at org.hibernate.engine.CascadingAction$1.cascade(CascadingAction.java:218)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:216)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:169)
at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
at org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:431)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:121)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:635)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:632)
at com.freiheit.extranet.partner.integration.persistence.hibernate.HibernatePartnerDAO.create(HibernatePartnerDAO.java:44)
at com.freiheit.extranet.InitDatabase$1.execute(InitDatabase.java:73)
at com.freiheit.extranet.BaseTest.withTransaction(BaseTest.java:60)
at com.freiheit.extranet.InitDatabase.testInitDatabase(InitDatabase.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.doRun(TestRunner.java:109)
at junit.textui.TestRunner.run(TestRunner.java:72)
at junit.textui.TestRunner.run(TestRunner.java:57)
at com.freiheit.extranet.InitDatabase.main(InitDatabase.java:39)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 20, 2007 6:15 am 
Newbie

Joined: Wed Jul 26, 2006 6:01 am
Posts: 10
Hallo ThomasBeckmann,

Hier wird es beschrieben:

http://www.hibernate.org/hib_docs/annotations/reference/en/html/additionalmodules.html#d0e3363

folgendes muss in hibernate.cfg.xml eingefugt werden.

Code:
<property name="hibernate.validator.apply_to_ddl">false</property>


Gruss Vaceslav Ustinov


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.