[Hibernate-JIRA] Created: (HV-389) Support conditional validation at property level
by jason shi (JIRA)
Support conditional validation at property level
------------------------------------------------
Key: HV-389
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-389
Project: Hibernate Validator
Issue Type: New Feature
Components: engine
Affects Versions: 4.1.0.Final
Reporter: jason shi
Assignee: Hardy Ferentschik
In Oval, there is a "when" attribute in each ConstrainsChecker,which can be used for conditional check.
In the following example fieldB must not be null only if fieldA is not null as well. With the prefix groovy: it is indicated that the formula is expressed in the Groovy language.
{code}
public class BusinessObject
{
private String fieldA;
@NotNull(when = "groovy:_this.fieldA != null")
private String fieldB;
}
{code}
Although we can use ScriptAssert as a work-around, but ScriptAssert can't be used at property level validation, and the "when" attribute make the validation logical more clearly.
In UI layer validation, this feature is very important in instant UI validation.
The hibernate validator should have the ability to pass a ValueContext to the Validator,then we can write a custom Contrains to implement this feature.
--
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
14 years, 8 months
[Hibernate-JIRA] Created: (HBX-1081) Generation of meta attributes for composite-id
by Anders Reinhardt Hansen (JIRA)
Generation of meta attributes for composite-id
----------------------------------------------
Key: HBX-1081
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-1081
Project: Hibernate Tools
Issue Type: Improvement
Components: reverse-engineer
Affects Versions: 3.2.beta11
Environment: All, not related to platform.
Reporter: Anders Reinhardt Hansen
Priority: Minor
The ReverseEngineeringStrategy has a method; "public Map tableToMetaAttributes(TableIdentifier tableIdentifier)"
This method returns a Map of meta tags which will be put inside the class node of the hbm files that are generated.
It would be a nice addition if we could have a method like this which placed meta tags inside the composite id node.
the method could be called "public Map tableToMetaAttributesForCompositeId(TableIdentifier tableIdentifier)"
An example of the problem is shown in the below example;
<class name="XXX1" table="XXX1">
<meta attribute="generated-class">XXX1Base</meta> <!-- this can be generated by tableToMetaAttributes() -->
<composite-id name="XXX2" class="XXX2">
<meta attribute="generated-class">XXX2Base</meta> <!-- this cannot be generated -->
<key-property name="propertyXXX" type="int">
<column name="ColoumnXXX" />
</key-property>
<key-property name="YYY" type="int">
<column name="ColoumnYYY" />
</key-property>
</composite-id>
...
</class>
The issue was discussed on the forum in topic http://forum.hibernate.org/viewtopic.php?t=989476
--
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
14 years, 8 months
[Hibernate-JIRA] Created: (HHH-6486) Negative ID created using Sequences
by Andreas Beckers (JIRA)
Negative ID created using Sequences
-----------------------------------
Key: HHH-6486
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6486
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 4.0.0.Beta4, 4.0.0.Beta1
Environment: JBoss 7.0.0.Final with Hibernate 4.0.0.Beta4, Oracle 10 Express
Reporter: Andreas Beckers
We use seperated sequences for each table. Our IDs are annotated like this:
@SequenceGenerator(name = "PersonGen", sequenceName = "person_id_seq")
@Id
@GeneratedValue(generator = "PersonGen")
public long getId() {
return _id;
}
The sequence is defined like this:
CREATE SEQUENCE person_id_seq START WITH 1 INCREMENT BY 1 NOCACHE;
The Problem is, that I get negative IDs in my object and the generated IDs are not unique. I get the error
java.sql.SQLIntegrityConstraintViolationException: ORA-00001: Unique Constraint (VESUVZPONF.PERSON_PKEY) verletzt
In the log I see:
Generated identifier: -21, using strategy: org.hibernate.id.enhanced.SequenceStyleGenerator
The code worked in JBoss 6.0.0.Final using Hibernate 3.6.0.Final
I tried auto strategy which uses a single sequence that works fine.
There are ManyToOne and OneToMany relations with cascade all, don't know if that's of importance.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 8 months
[Hibernate-JIRA] Created: (OGM-63) Remove unused code branches and unnecessary null checks
by Juraci Paixao Krohling (JIRA)
Remove unused code branches and unnecessary null checks
-------------------------------------------------------
Key: OGM-63
URL: http://opensource.atlassian.com/projects/hibernate/browse/OGM-63
Project: Hibernate OGM
Issue Type: Improvement
Components: core
Affects Versions: 3.0.0.Alpha1
Reporter: Juraci Paixao Krohling
Assignee: Juraci Paixao Krohling
Fix For: 3.0-next
I ran the FindBugs code analysis tool and noticed that there are some unnecessary null checks and unused code branches in Hibernate OGM Core module, like the following example from OgmLoader:
{code:title=OgmLoader.java}
//we don't load more than one instance per row, shortcircuiting it for the moment
final int[] collectionOwners = null;
for ( int i=0; i<collectionPersisters.length; i++ ) {
final CollectionAliases[] descriptors = getCollectionAliases();
final boolean hasCollectionOwners = collectionOwners !=null &&
collectionOwners[i] > -1;
//true if this is a query and we are loading multiple instances of the same collection role
//otherwise this is a CollectionInitializer and we are loading up a single collection or batch
final Object owner = hasCollectionOwners ?
row[ collectionOwners[i] ] :
null; //if null, owner will be retrieved from session
final CollectionPersister collectionPersister = collectionPersisters[i];
final Serializable key;
if ( owner == null ) {
key = null;
}
else {
key = collectionPersister.getCollectionType().getKeyOfOwner( owner, session );
//TODO: old version did not require hashmap lookup:
//keys[collectionOwner].getIdentifier()
}
readCollectionElement(
owner,
key,
collectionPersister,
descriptors[i],
resultSet, //TODO CURRENT must use the same instance across all calls
session
);
{code}
Note that {{collectionOwners}} is always {{null}}. Thus, {{hasCollectionOwners}} is always {{false}}, causing {{owner}} to always be {{null}}. Then, the {{if ( owner == null ) }} will always be evaluated as true, turning the else part to be unnecessary. The above code can be rewritten as:
{code:title=OgmLoader.java}
final CollectionAliases[] descriptors = getCollectionAliases(); // this line was inside the for loop... it seems it can be outside
for ( int i=0; i<collectionPersisters.length; i++ ) {
final CollectionPersister collectionPersister = collectionPersisters[i];
readCollectionElement(
null,
null,
collectionPersister,
descriptors[i],
resultSet, //TODO CURRENT must use the same instance across all calls
session
);
}
{code}
This JIRA is to track similar issues to the example above.
--
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
14 years, 8 months