[Hibernate-JIRA] Created: (HHH-6591) JPA QL's NEW MyClass(...) construct fails - number of constructor params used during validation
by Ondrej Zizka (JIRA)
JPA QL's NEW MyClass(...) construct fails - number of constructor params used during validation
-----------------------------------------------------------------------------------------------
Key: HHH-6591
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6591
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.6.6, 3.6.5, 3.6.4
Reporter: Ondrej Zizka
Priority: Critical
This
{code}
List<MyClass> list = em.createQuery("SELECT NEW org.test.MyClass( 'Foo', 123 ) FROM IrcEvent ev", MyClass.class).getResultList();
{code}
and this
{code}
List<Object[]> list = em.createQuery("SELECT 'Foo', 123 FROM IrcEvent ev", Object[].class).getResultList();
{code}
ends up with:
{quote}
java.lang.IllegalArgumentException: Cannot create TypedQuery for query with more than one return
{quote}
Both should work according to docs.
This has been reported and worked on as per HHH-5348, but the issue prevails.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 6 months
[Hibernate-JIRA] Created: (HV-345) Run automated diff between project model constraints and database model constraints
by Roman Arkadijovych Muntyanu (JIRA)
Run automated diff between project model constraints and database model constraints
-----------------------------------------------------------------------------------
Key: HV-345
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-345
Project: Hibernate Validator
Issue Type: New Feature
Components: engine
Affects Versions: 4.2.0
Reporter: Roman Arkadijovych Muntyanu
Assignee: Hardy Ferentschik
[This feature request has been added to this project due to relation to Java-level constraint validation. Please feel free moving it to appropriate project]
Since constraints validation is added at Java model level, it would be interesting to write a tool, that would do the following during application start-up:
* poll the database for schema;
* poll hibernate for XML/JPA Mappings;
* compare two of the above to constraints defined through validation framework and generate warnings in the logs.
For the initial version this could be simple checks like size of field defined in DB and in the model, field mandatority etc.
This would help a lot in keeping consistency between database and business constraints model.
--
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, 6 months
[Hibernate-JIRA] Created: (HHH-5832) JPA Query and IdClass Causing NullPointerException
by Erich Heard (JIRA)
JPA Query and IdClass Causing NullPointerException
--------------------------------------------------
Key: HHH-5832
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5832
Project: Hibernate Core
Issue Type: Bug
Components: metamodel
Affects Versions: 3.5.1
Environment: Hibernate version 3.5.1 and Oracle 10g.
Reporter: Erich Heard
We had an issue when building queries dynamically with JPA objects when we accessed an @Id property of an entity class that used @IdClass. Under these conditions, Path.get( ) would return null. Here is a short illustration:
The entity was specified like:
@Entity
// snipped more annotations
@IdClass( RetailerId.class )
public class Retailer {
@Id
private String retailerId;
public String getRetailerId( ) { return this.retailerId; }
public void setRetailerId( String value ) { this.retailerId = value; }
@Id
private String divisionCode;
public String getDivisionCode( ) { return this.divisionCode; }
public void setDivisionCode( String value ) { this.divisionCode = value; }
// snipped other attributes
}
And the ID class was specified like:
@Embeddable
public class RetailerId implements Serializable {
private static final long serialVersionUID = -2639451633891197777L;
@Column( name = "RETLR_ID", nullable = false, length = 7 )
private String retailerId;
public String getRetailerId( ) { return this.retailerId; }
public void setRetailerId( String value ) { this.retailerId = value; }
@Column( name = "DIV_CDE", nullable = false, length = 2 )
private String divisionCode;
public String getDivisionCode( ) { return this.divisionCode; }
public void setDivisionCode( String value ) { this.divisionCode = value; }
// snipped implementations of Serializable methods
}
The code that caused the error condition:
CriteriaQuery<RetailerConfigurationPreference> query = cb.createQuery(RetailerConfigurationPreference.class);
Root<RetailerConfigurationPreference> root = query.from(RetailerConfigurationPreference.class);
Predicate predicate = root.get("retailer").get("retailerId").in(retailerIds);
In this case, the 'get("retailerId")' would return null. To get around this issue, I altered the class org.hibernate.ejb.metamodel.AbstractIdentifiableType and overrode its super method getAttribute() to check the ID class for the attribute before deferring to its superclass.
@Override
public Attribute<? super X, ?> getAttribute(String name) {
if( this.idClassAttributes != null ) {
Attribute<? super X, ?> attribute = null;
Iterator<SingularAttribute<? super X, ?>> i = this.idClassAttributes.iterator( );
while( i.hasNext( ) ) {
attribute = i.next( );
if( attribute.getName( ).equals( name ) ) return attribute;
}
}
return super.getAttribute( name );
}
I didn't test this with EmbeddedId - that may work as is or it may need a case of its own. This is the first time I've submitted anything here, so I apologize if it is not to form.
--
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, 6 months
[Hibernate-JIRA] Created: (BVAL-224) Provide a way for accessing default implementations for XML configured bootstrap artifacts
by Gunnar Morling (JIRA)
Provide a way for accessing default implementations for XML configured bootstrap artifacts
------------------------------------------------------------------------------------------
Key: BVAL-224
URL: http://opensource.atlassian.com/projects/hibernate/browse/BVAL-224
Project: Bean Validation
Issue Type: New Feature
Components: spec-general
Reporter: Gunnar Morling
Using {{validation.xml}} one can specify custom implementations for constraint validator factory, message interpolator etc. Right now there is no way to delegate from within these custom implementations to the default ones. This would be possible when using the configuration API:
{code}
HibernateValidatorConfiguration configuration = Validation.byProvider(HibernateValidator.class).configure();
ConstraintValidatorFactory defaultFactory = configuration.getDefaultConstraintValidatorFactory();
ConstraintValidatorFactory customFactory = new CustomConstraintValidatorFactory(defaultFactory);
configuration.constraintValidatorFactory(customFactory);
{code}
One idea to allow for such a delegation is to support constructors taking the default implementation as parameter:
{code}
CustomConstraintValidatorFactory implements ConstraintValidatorFactory {
ConstraintValidatorFactory delegate;
CustomConstraintValidatorFactory(ConstraintValidatorFactory defaultFactory) {
this.delegate = defaultFactory;
}
}
{code}
For XML-configured artifacts the runtime could invoke this delegate constructor if existent, otherwise the default constructor could be invoked.
--
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, 6 months
[Hibernate-JIRA] Created: (BVAL-235) Support parameterized payload attributes
by Sebastian Thomschke (JIRA)
Support parameterized payload attributes
----------------------------------------
Key: BVAL-235
URL: http://opensource.atlassian.com/projects/hibernate/browse/BVAL-235
Project: Bean Validation
Issue Type: New Feature
Components: spec-general
Affects Versions: 1.0 final
Reporter: Sebastian Thomschke
JSR303's payload attribute values are limited to class references.
The idea is to allow the specification of an additional String value for each payload declaration allowing more flexible configurations.
For example:
public @interface Payload {
Class< ? > type();
String value();
}
@interface MinLength {
Payload[] payload() default {};
// ...
}
class Account
{
@MinLength(value=4, payload = {
@Payload(type=ErrorCode.class, value="1234"),
@Payload(type=When.class, value="groovy:this.owner != null && this.foobar > 3")
})
String name;
}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 6 months
[Hibernate-JIRA] Created: (HV-492) Validation of CGLIB enhanced Objects always return null
by Christian Fehmer (JIRA)
Validation of CGLIB enhanced Objects always return null
-------------------------------------------------------
Key: HV-492
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-492
Project: Hibernate Validator
Issue Type: Bug
Affects Versions: 4.2.0.Beta2, 4.1.0.Final
Environment: Hibernate Validator 4.1.0-final and 4.2.0-BETA2, cglib 2.2
Reporter: Christian Fehmer
A validation of a cglib enhanced object will always validate "null".
The validator (i tested it with an custom validator) always gets "null" as the value in the isValid method. The cglib enhanced object has a field "selection" and a getter/setter pair for this field. The hibernate validator uses the org.hibernate.validator.util.ReflectionHelper to access the field selection directly. That fails on a cglib enhanced object.
My workaround for now: I replaced the org.hibernate.validator.util.ReflectionHelper.getValue method. When object is a cglib enhanced object i invoke the getter method instead of accessing the field directly.
replaced method:
public static Object getValue(Member member, Object object) {
Object value = null;
if (member instanceof Method) {
...
} else if (member instanceof Field) {
// FIX: use getter method on cglib fields
if (object.getClass().getName().contains("$$")) {
String methodName = member.getName();
methodName = "get"+ String.valueOf(methodName.charAt(0)).toUpperCase()+ methodName.substring(1);
try {
Method method = member.getDeclaringClass().getMethod(
methodName);
method.setAccessible(true);
value = method.invoke(object);
} catch (Exception e) {
throw new ValidationException("Unable to access "
+ methodName, e);
}
} else {
...
}
}
return value;
}
--
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, 6 months