[Hibernate-JIRA] Created: (HV-52) unified unit testing pattern for standalone validators
by Sanne Grinovero (JIRA)
unified unit testing pattern for standalone validators
------------------------------------------------------
Key: HV-52
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-52
Project: Hibernate Validator
Issue Type: Patch
Affects Versions: 3.0.0.ga
Reporter: Sanne Grinovero
Priority: Minor
Attachments: validator-testing-cleanup.patch
Hi,
I've seen some bugs in the validator I would like to help solving, but the main issue I've seen is that to
write unittests the code is quite verbose; the consequence is that mission-critical code is well tested
but most trivial code is untested.
It looks like to me that most JIRA issues here are relevant to this "untested trivial" code...
I would appreciate if you could apply this patch that greatly simplifies writing of unit tests for standalone validators,
as I would like to send some more patches using this code to develop test-first.
This affects only the "test" source, diffed from 3.0.0.GA, and includes some new testing of
@NotEmpty and @Digits; I would add much more tests if you're not against it.
With "standalone validators" i mean that this is not useful for graph/integration testing,
just each validator on some property.
Sanne
--
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
15 years, 10 months
[Hibernate-JIRA] Created: (HV-42) Reference Documentation: broken example
by Robert Spielmann (JIRA)
Reference Documentation: broken example
---------------------------------------
Key: HV-42
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-42
Project: Hibernate Validator
Issue Type: Bug
Components: documentation
Reporter: Robert Spielmann
Priority: Trivial
The Hibernate Validator Reference Guide (Hibernate Validator 3.0.0.GA) contains examples for writing custom annotations and validators, section 1.4 "writing your own constraints". There, it says that the class CapitalizedValidator implements Validator<Capitalized> and PropertyConstraint. The example class, however, does not implement the "apply" method. Thus, the example class does not compile.
Additionally, the class "Capitalize" (containing constants like FIRST) is not defined anywhere. This leaves the example incomplete and thus - unless you quickly implement this class - unsuable for practical experiments.
--
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
15 years, 10 months
[Hibernate-JIRA] Created: (HV-25) Generated DDL ignores Validator annotations on component fields and superclass fields
by Ben Anderson (JIRA)
Generated DDL ignores Validator annotations on component fields and superclass fields
-------------------------------------------------------------------------------------
Key: HV-25
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-25
Project: Hibernate Validator
Issue Type: Bug
Components: engine
Affects Versions: 3.0.0.ga
Environment: Windows XP, Hibernate 3.2.4.sp1, Hibernate Annotations 3.3.0.ga, Postgres, HSQL
Reporter: Ben Anderson
Attachments: model.zip
The DDL generated for entities containing components or superclass properties does not reflect any Validator length restrictions or not-null constraints that have been defined on those component or superclass properties i.e. a component with a property containing the @Length(max = 50) and @NotNull annotation is generated as varchar(255) with nulls permitted (at the database level).
I've posted a more detailed example to the forum at http://forum.hibernate.org/viewtopic.php?t=975612
Another example can be found at http://www.ibm.com/developerworks/web/library/j-hibval.html - the SQL generated when this schema is exported is:
create table cc (id integer not null, fname varchar(255), mi varchar(255), lname varchar(255), addr1 varchar(255), addr2 varchar(255), city varchar(255), zipcode varchar(255), state_id varchar(255), cvv2 varchar(6) not null, expiration_date timestamp not null, type_id integer not null, num varchar(30) not null, customer_id integer not null, primary key (id));
create table customer (id integer not null, dob timestamp, phone varchar(255), fax varchar(255), email varchar(255), fname varchar(255), mi varchar(255), lname varchar(255), addr1 varchar(255), addr2 varchar(255), city varchar(255), zipcode varchar(255), state_id varchar(255), primary key (id));
The SQL should be:
create table cc (id integer not null, fname varchar(30) not null, mi varchar(1), lname varchar(30) not null, addr1 varchar(50) not null, addr2 varchar(50), city varchar(50) not null, zipcode varchar(15) not null, state_id varchar(2) not null, cvv2 varchar(6) not null, expiration_date timestamp not null, type_id integer not null, num varchar(30) not null, customer_id integer not null, primary key (id));
create table customer (id integer not null, dob timestamp, phone varchar(13), fax varchar(13), email varchar(40), fname varchar(30) not null, mi varchar(1), lname varchar(30) not null, addr1 varchar(50) not null, addr2 varchar(50) not null, city varchar(50) not null, zipcode varchar(15) not null, state_id varchar(2) not null, primary key (id));
I've attached the relevant classes from this example.
--
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
15 years, 10 months
[Hibernate-JIRA] Created: (HV-22) Provide contextual validation
by Emmanuel Bernard (JIRA)
Provide contextual validation
-----------------------------
Key: HV-22
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-22
Project: Hibernate Validator
Issue Type: New Feature
Components: engine
Reporter: Emmanuel Bernard
The basic idea is to have a special parameter in annotations named context(s)
@NotNull(message="doh", context = {"screen1Input", "screen2Input", "default"})
"default" being a special context, the one applied every time (including in the DDL)
no context or an empty context is equivalent to "default"
The regular API are running against "default"
Override the regular APIs with getInvalidValues(..., String context);
Not entirely sure the idea will float, but it sounds like a non invasive way to do it.
PS this might require to create @[Name]s annotations ie @NotNulls({@NotNull(message="m1", context="earlyStage"), @NotNull(message="m2")})
--
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
15 years, 10 months
[Hibernate-JIRA] Created: (HV-28) "connection already null in cleanup" when using validators
by David J. M. Karlsen (JIRA)
"connection already null in cleanup" when using validators
----------------------------------------------------------
Key: HV-28
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-28
Project: Hibernate Validator
Issue Type: Bug
Environment: hibernate annotations 3.3.0ga
hibernate validator 3.0.0ga
hibernate 3.2.4.sp1
hibernate-commons-annotations 3.3.0.ga
Reporter: David J. M. Karlsen
Priority: Critical
2007-06-27 21:18:39,133 [WorkManager.DefaultWorkManager : 0] DEBUG org.hibernate.impl.SessionImpl - opened session at timestamp: 11829719154 (SessionImpl.java:220)
2007-06-27 21:18:39,159 [WorkManager.DefaultWorkManager : 0] TRACE org.hibernate.event.def.DefaultSaveOrUpdateEventListener - saving transient instance (DefaultSaveOrUpdateEventListener.java:158)
2007-06-27 21:18:39,162 [WorkManager.DefaultWorkManager : 0] DEBUG org.hibernate.event.def.AbstractSaveEventListener - generated identifier: e2632934-a800-4a91-a9ff-ce8e1f95a03d, using strategy: org.hibernate.id.Assigned (AbstractSaveE
ventListener.java:112)
2007-06-27 21:18:39,168 [WorkManager.DefaultWorkManager : 0] TRACE org.hibernate.event.def.AbstractSaveEventListener - saving [mypackage.server.types.Fee#e2632934-a800-4a91-a9ff-ce8e1f95a03d] (AbstractSaveEventListener.java:
153)
2007-06-27 21:18:39,228 [WorkManager.DefaultWorkManager : 0] TRACE org.hibernate.event.def.AbstractFlushingEventListener - flushing session (AbstractFlushingEventListener.java:58)
2007-06-27 21:18:39,232 [WorkManager.DefaultWorkManager : 0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - processing flush-time cascades (AbstractFlushingEventListener.java:111)
2007-06-27 21:18:39,237 [WorkManager.DefaultWorkManager : 0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - dirty checking collections (AbstractFlushingEventListener.java:154)
2007-06-27 21:18:39,238 [WorkManager.DefaultWorkManager : 0] TRACE org.hibernate.event.def.AbstractFlushingEventListener - Flushing entities and processing referenced collections (AbstractFlushingEventListener.java:171)
2007-06-27 21:18:39,249 [WorkManager.DefaultWorkManager : 0] TRACE org.hibernate.event.def.AbstractFlushingEventListener - Processing unreferenced collections (AbstractFlushingEventListener.java:210)
2007-06-27 21:18:39,251 [WorkManager.DefaultWorkManager : 0] TRACE org.hibernate.event.def.AbstractFlushingEventListener - Scheduling collection removes/(re)creates/updates (AbstractFlushingEventListener.java:224)
2007-06-27 21:18:39,252 [WorkManager.DefaultWorkManager : 0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects (AbstractFlushingEventListener.java:85)
2007-06-27 21:18:39,254 [WorkManager.DefaultWorkManager : 0] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections (AbstractFlushingEventListener.java:91)
2007-06-27 21:18:39,260 [WorkManager.DefaultWorkManager : 0] DEBUG org.hibernate.pretty.Printer - listing entities: (Printer.java:83)
2007-06-27 21:18:39,262 [WorkManager.DefaultWorkManager : 0] DEBUG org.hibernate.pretty.Printer - mypackage.types.Fee{<values anonymized>} (Printer.java:90)
2007-06-27 21:18:39,264 [WorkManager.DefaultWorkManager : 0] TRACE org.hibernate.event.def.AbstractFlushingEventListener - executing flush (AbstractFlushingEventListener.java:290)
2007-06-27 21:18:39,265 [WorkManager.DefaultWorkManager : 0] TRACE org.hibernate.jdbc.ConnectionManager - registering flush begin (ConnectionManager.java:469)
2007-06-27 21:18:39,276 [WorkManager.DefaultWorkManager : 0] TRACE org.hibernate.jdbc.ConnectionManager - registering flush end (ConnectionManager.java:478)
2007-06-27 21:18:39,278 [WorkManager.DefaultWorkManager : 0] TRACE org.hibernate.impl.SessionImpl - after transaction completion (SessionImpl.java:422)
2007-06-27 21:18:39,280 [WorkManager.DefaultWorkManager : 0] TRACE org.hibernate.impl.SessionImpl - closing session (SessionImpl.java:273)
2007-06-27 21:18:39,281 [WorkManager.DefaultWorkManager : 0] TRACE org.hibernate.jdbc.ConnectionManager - connection already null in cleanup : no action (ConnectionManager.java:375)
2007-06-27 21:18:39,298 [WorkManager.DefaultWorkManager : 0] ERROR Could not insert Fee
org.hibernate.validator.InvalidStateException: validation failed for: mypackage.server.types.Fee
at org.hibernate.validator.event.ValidateEventListener.validate(ValidateEventListener.java:148)
at org.hibernate.validator.event.ValidateEventListener.onPreInsert(ValidateEventListener.java:172)
at org.hibernate.action.EntityInsertAction.preInsert(EntityInsertAction.java:156)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:49)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
This only seems to happen when I'm running inside an appserver (WebSphere 6.1) with pooled connections - in my unit-tests using a org.springframework.jdbc.datasource.DriverManagerDataSource (eg. non-pooled) it works OK - and only if adding validating annotations (@NotEmpty)
--
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
15 years, 10 months
[Hibernate-JIRA] Created: (HV-37) Validating a lazy collection of composite-elements causes flush problem
by Ian Long (JIRA)
Validating a lazy collection of composite-elements causes flush problem
------------------------------------------------------------------------
Key: HV-37
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-37
Project: Hibernate Validator
Issue Type: Bug
Affects Versions: 3.0.0.ga
Environment: Hibernate 3.2.4ga
Hibernate Annotations 3.3.0.ga
mysql 5.0.27
Reporter: Ian Long
Using the event listeners(pre-update,pre-insert) in hibernate, a problem occurs when validating a lazy collection of composite-elements.
I was using the @Size validator, but I'm sure others will cause the same problem.
For example:
<set name="activatedModules"
lazy="true"
table="location_module_activation">
<key column="location_id" />
<composite-element class="com.opterus.opscenter.model.module.ActivatedModule" >
<property name="activationDate" column="activate_date" not-null="true" />
<many-to-one name="module" class="com.opterus.opscenter.model.module.Module" column="module_id" not-null="true" unique="false" />
</composite-element>
</set>
will cause an exception during flush:
01:53:55,587 ERROR [http-8080-Processor23] AssertionFailure:22 - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: collection [com.opterus.opscenter.model.common.Brand.regions] was not processed by flush()
at org.hibernate.engine.CollectionEntry.postFlush(CollectionEntry.java:205)
at org.hibernate.event.def.AbstractFlushingEventListener.postFlush(AbstractFlushingEventListener.java:333)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:28)
Since it tries to access the proxied collection. A collection of entity objects does not cause this problem.
I guess the composite-element is handled differently than regular collections?
Filed at the request of emmanuel, from the following thread: http://forum.hibernate.org/viewtopic.php?p=2361829#2361829
--
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
15 years, 10 months