[Hibernate-JIRA] Created: (HHH-5948) Trying to get a PluralAttributePath from a @MappedSuperclass throws org.hibernate.MappingException: Unknown collection role
by Oliver Ringel (JIRA)
Trying to get a PluralAttributePath from a @MappedSuperclass throws org.hibernate.MappingException: Unknown collection role
----------------------------------------------------------------------------------------------------------------------------
Key: HHH-5948
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5948
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.6.1, 3.6.0
Reporter: Oliver Ringel
Attachments: testcase-hibernate.tgz
I'm trying to get the PluralAttributePath from a collection defined in a MappedSuperclass
@Entity
public class Person extends PersonBase {
@Basic
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@MappedSuperclass
public abstract class PersonBase {
@Id
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@OneToMany()
private Set<Address> addresses = new HashSet<Address>();
public Set<Address> getAddresses() {
return addresses;
}
public void setAddresses(Set<Address> addresses) {
this.addresses = addresses;
}
}
Executing the following
criteriaQuery = criteriaBuilder.createQuery(Person.class);
root = criteriaQuery.from(Person.class);
Path<?> pathAddresses = root.get("addresses");
throws the exception
org.hibernate.MappingException: Unknown collection role: testcase.hibernate.PersonBase.addresses
at org.hibernate.impl.SessionFactoryImpl.getCollectionPersister(SessionFactoryImpl.java:701)
at org.hibernate.ejb.criteria.path.PluralAttributePath.resolvePersister(PluralAttributePath.java:58)
at org.hibernate.ejb.criteria.path.PluralAttributePath.<init>(PluralAttributePath.java:52)
at org.hibernate.ejb.criteria.path.AbstractPathImpl.get(AbstractPathImpl.java:157)
at org.hibernate.ejb.criteria.path.AbstractPathImpl.get(AbstractPathImpl.java:197)
at testcase.hibernate.HibernateTest.testMappedSuperclassPluralAttribute(HibernateTest.java:53)
--
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
13 years
[Hibernate-JIRA] Created: (HHH-6917) Persist deleted entity in collection which is not removed from collection
by Wong D (JIRA)
Persist deleted entity in collection which is not removed from collection
-------------------------------------------------------------------------
Key: HHH-6917
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6917
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.6.9, 4.0.0.Final
Environment: PostgreSQL 9.0.4, MySQL 5.5, Spring 3.1, JPA 2.0
Reporter: Wong D
Attachments: delete-test-src.zip
In one-to-many relationship, hibernate will not delete the entity from the collection if the entity is deleted from the outside and was not removed from the collection. For example, we have two classes:
class A { @OneToMany(cascade=CascadeType.ALL) Collection<B> bs; }
class B { @ManyToOne A a;}
A has a collection of B, say b1, b2, b3.
The following code will raise EntityNotFoundException: deleted entity passed to persist B#null
for(B b : A.bs) {
BService.delete(b); // No call to persist(A)
}
After we delete the b1, the deletion of b2 will cause the error. A complete test case attached.
I found out before each query org.hibernate.event.def.AbstractFlushingEventListener class calls prepareEntityFlushes(EventSource session). If I delete one entity B but did not remove it from the collection A.bs, Hibernate will throw the exception "deleted entity passed to persist" when persisting A, even I did not call persist A. So the exception could be thrown any time (for example, it throws when I execute a SELECT query).
I am expecting a transparent action that Hibernate will update the collection directly. BTW, I test eclipselink and it did not complain about deleted entity.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years
[Hibernate-JIRA] Created: (HHH-6880) Implementations of org.hibernate.type.Type contain references to non-serializable entities
by Mindaugas Žakšauskas (JIRA)
Implementations of org.hibernate.type.Type contain references to non-serializable entities
------------------------------------------------------------------------------------------
Key: HHH-6880
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6880
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.7
Environment: Seen this on MySQL but I believe this is environment-agnostic
Reporter: Mindaugas Žakšauskas
Priority: Critical
This is a spin-off from
- https://forum.hibernate.org/viewtopic.php?f=1&t=1013687&sid=e62b8ea711e49...
- http://stackoverflow.com/q/8404559/7345
org.hibernate.cache.CacheKey is an object which is used for L2 cache notifications - e.g. to flush a cache on a different cluster node when a certain object has been updated.
The problem comes from org.hibernate.cache.CacheKey carrying the type which (sometimes) happens to have a reference to objects like org.hibernate.impl.SessionFactoryImpl.
This problem is actually not just theoretic but also causes real pain. First, it takes much longer to broadcast cache flush events. Secondly, I get this exception during deserialization of such a CacheKey:
java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:768)
at org.hibernate.impl.SessionFactoryObjectFactory.getNamedInstance(SessionFactoryObjectFactory.java:159)
at org.hibernate.impl.SessionFactoryImpl.readResolve(SessionFactoryImpl.java:753)
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 java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1061)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1762)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readUnshared(ObjectInputStream.java:441)
at my.class.deserializeKey(EhcacheUtils.java:35)
I have done a quick scan through all the types, and found these problems related to their serializability:
1) org.hibernate.type.CollectionType, org.hibernate.type.ComponentType and subclasses of both - they use attribute "typeScope" (of type TypeFactory.TypeScope) which is assigned in the constructor and kept in the but seems to be never used. The typeScope in turn has a reference to the SessionImpl. Can it simply be removed?
2) org.hibernate.type.EntityType (and its subclasses) stores typeScope and only uses it in the getter, so I guess it should be safe to remove it, too.
3) org.hibernate.type.SortedSetType and org.hibernate.type.SortedMapType keeps a reference to the comparator, but does not enforce its serializability. It should at least throw a runtime exception in org.hibernate.mapping.Collection::getComparator if the comparator is not serializable.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years
[Hibernate-JIRA] Created: (HV-547) Make Hibernate Validator build not fail
by Emmanuel Bernard (JIRA)
Make Hibernate Validator build not fail
---------------------------------------
Key: HV-547
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-547
Project: Hibernate Validator
Issue Type: Improvement
Components: build
Reporter: Emmanuel Bernard
When running mvn clean install, I always get failures on the manual build.
{code}
[INFO] Hibernate Validator Aggregator .................... SUCCESS [1.319s]
[INFO] Hibernate Validator ............................... SUCCESS [27.278s]
[INFO] Hibernate Validator TCK Runner .................... SUCCESS [19.637s]
[INFO] Hibernate Validator Integration Tests ............. SUCCESS [26.355s]
[INFO] Hibernate Validator Annotation Processor .......... SUCCESS [3.330s]
[INFO] Hibernate Validator Quickstart .................... SUCCESS [12.296s]
[INFO] Hibernate Validator Manual ........................ FAILURE [19.885s]
[INFO] Hibernate Validator Distribution .................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:55.078s
[INFO] Finished at: Fri Dec 23 14:36:25 CET 2011
[INFO] Final Memory: 45M/108M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jboss.maven.plugins:maven-jdocbook-plugin:2.3.5:translate (default) on project hibernate-validator-documentation: Unexpected problem: unable to execute po2xml : Cannot run program "po2xml": error=2, No such file or directory -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :hibernate-validator-documentation
{code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years
[Hibernate-JIRA] Created: (HV-512) Composed constraints lose the payload information of the constraints they are composed of
by Geoff The (JIRA)
Composed constraints lose the payload information of the constraints they are composed of
-----------------------------------------------------------------------------------------
Key: HV-512
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-512
Project: Hibernate Validator
Issue Type: Bug
Components: validators
Affects Versions: 4.2.0.Final
Reporter: Geoff The
If a payload is set for child constraints in a composed constraint, their payload values will be ignored.
HV-183 dealt with the propagation of the parent's payload down to the children constraints, but it also overwrites any payload the children may have had.
I would suggest that if the children have any explicit payloads defined, they should be integrated into the parents and not blown away.
{code}
import org.junit.*;
import javax.validation.*;
import javax.validation.constraints.NotNull;
import java.lang.annotation.*;
import java.util.*;
import static org.junit.Assert.*;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
public class TestPayload {
public static class Warning implements Payload {}
public static class Error implements Payload {}
@Documented
@Constraint(validatedBy = NameMustBeGeoffValidator.class)
@Target({ TYPE, METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
@Retention(RUNTIME)
public @interface NameMustBeGeoff {
String message() default "{NameMustBeGeoff.message}";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
public static class NameMustBeGeoffValidator implements ConstraintValidator<NameMustBeGeoff, Customer> {
@Override
public void initialize(NameMustBeGeoff constraintAnnotation) {}
@Override
public boolean isValid(Customer value, ConstraintValidatorContext context) {
return ((value.getName() == null) || (value.getName().equals("Geoff")));
}
}
@NameMustBeGeoff(payload = Error.class)
@Documented
@Constraint(validatedBy = ValidCustomerValidator.class)
@Target({ TYPE, METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
@Retention(RUNTIME)
public @interface ValidCustomer {
String message() default "{ValidCustomer.message}";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
public static class ValidCustomerValidator implements ConstraintValidator<ValidCustomer, Customer> {
@Override
public void initialize(ValidCustomer constraintAnnotation) {}
@Override
public boolean isValid(Customer value, ConstraintValidatorContext context) { return true; }
}
@ValidCustomer
public class Customer {
private String name;
public Customer(String name) { this.name = name; }
@NotNull(payload = Warning.class)
public String getName() { return this.name; }
}
/**
* Customer's name is null, it should trigger the @NotNull with a Warning payload
*/
@Test
public void test() {
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
Customer customer = new Customer(null);
Set<ConstraintViolation<Customer>> violations = validator.validate(customer);
assertEquals(1, violations.size());
ConstraintViolation<Customer> violation = violations.iterator().next();
assertEquals("may not be null", violation.getMessage());
assertEquals("javax.validation.constraints.NotNull", violation.getConstraintDescriptor().getAnnotation().annotationType().getName());
assertEquals(1, violation.getConstraintDescriptor().getPayload().size());
assertEquals(Warning.class, violation.getConstraintDescriptor().getPayload().iterator().next());
}
/**
* Customer's name is not Geoff and should trigger the NameMustBeGeoff constraint, but the Error payload is lost
*/
@Test
public void testPayloadInComposedConstraints() {
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
Customer customer = new Customer("Bob");
Set<ConstraintViolation<Customer>> violations = validator.validate(customer);
assertEquals(1, violations.size());
ConstraintViolation<Customer> violation = violations.iterator().next();
assertEquals("{NameMustBeGeoff.message}", violation.getMessage());
assertEquals("org.geofft.TestPayload$NameMustBeGeoff", violation.getConstraintDescriptor().getAnnotation().annotationType().getName());
assertEquals(0, violation.getConstraintDescriptor().getPayload().size()); // Not what I expected
/*
What I think should happen:
assertEquals(1, violation.getConstraintDescriptor().getPayload().size());
assertEquals(Customer.Error.class, violation.getConstraintDescriptor().getPayload().iterator().next());
*/
}
}
{code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years