[Hibernate-JIRA] Created: (HHH-5024) MetadataContext#registerAttribute does not recognize inherited fields
by Adrian Hummel (JIRA)
MetadataContext#registerAttribute does not recognize inherited fields
---------------------------------------------------------------------
Key: HHH-5024
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5024
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager, metamodel
Affects Versions: 3.5.0-CR-2
Environment: Hibernate 3.5.0-CR-2, JPA Modelgen 1.0.0-CR-1
Reporter: Adrian Hummel
Priority: Critical
Attachments: bugreport.zip
The embeddable class {{CustomerId}} (see attached ZIP) inherits from the base class {{AbstractIdentity}} (annotated with {{@MappedSuperclass}}). The metamodel classes for these two classes are correctly generated:
{code:title=AbstractIdentity_.java|borderStyle=solid}
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;
@StaticMetamodel(AbstractIdentity.class)
public abstract class AbstractIdentity_ {
public static volatile SingularAttribute<AbstractIdentity, String> id;
}
{code}
and
{code:title=CustomerId_.java|borderStyle=solid}
import javax.persistence.metamodel.StaticMetamodel;
@StaticMetamodel(CustomerId.class)
public abstract class CustomerId_ extends AbstractIdentity_ {
}
{code}
When building the entity manager factory, {{MetadataContext#registerAttribute}} (line 378) tries to resolve the field {{CustomerId_.id}} using {{Class#getDeclaredField}}. This results in a {{NoSuchFieldException}} because the field is declared in the super class {{AbstractIdentity_}}.
Proposed solution: Since all field declarations in the metamodel are public, the {{Class#getField}} method should be used instead.
--
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
12 years, 11 months
[Hibernate-JIRA] Created: (HHH-6605) Storing information about changes of properties
by Michał Skowronek (JIRA)
Storing information about changes of properties
-----------------------------------------------
Key: HHH-6605
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6605
Project: Hibernate Core
Issue Type: New Feature
Components: envers
Affects Versions: 4.x
Reporter: Michał Skowronek
Users would be able to construct more meaningful audit queries if Envers had an option to store and query information about modifications of individual properties, e.g.:
getAuditReader().createQuery().forRevisionsOfEntity(clazz, false, false)
.add(AuditEntity.id().eq(id)).add(AuditEntity.property(propertyName).hasChanged());
With such a query, user will get only those revisions of (clazz, id), that modified property with propertyName.
Currently, to achieve that, user have to retrieve and compare manually two revisions, which increases complexity and decreases performance.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 11 months
[Hibernate-JIRA] Created: (HHH-3853) one-to-one mapping doesn support Primary Key Association
by Amar Singh (JIRA)
one-to-one mapping doesn support Primary Key Association
--------------------------------------------------------
Key: HHH-3853
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3853
Project: Hibernate Core
Issue Type: Bug
Components: envers
Environment: Hibernate - core 3.4.0-SNAPSHOT, Hibernate - envers (trunk build from today)
Reporter: Amar Singh
Attachments: one-to-one-pk.zip
one-to-one mapping with primary key association doesn't seem to be working. Eg.
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.hibernate.envers.test.integration.onetoone.bidirectional" default-lazy="false">
<class name="BidirectionalRefIngPK" table="BIDIRECTIONAL_REFERENCING_ENTITY">
<id name="id" type="long" column="BIDIRECTIONAL_REFERENCING_ID" >
<generator class="foreign">
<param name="property">reference</param>
</generator>
</id>
<property name="data"/>
<property column="BIDIRECTIONAL_REFERENCING_ID" generated="never" insert="false" lazy="false" name="id" type="long" update="false"/>
<one-to-one name="reference" cascade="save-update" class="BidirectionalRefEdPK" constrained="true" />
</class>
<class name="BidirectionalRefEdPK" table="BIDIRECTIONAL_REFERENCED_ENTITY">
<id name="longId" type="long" column="BIDIRECTIONAL_REFERENCED_ID">
<generator class="native"/>
</id>
<property name="data"/>
<one-to-one name="referencing" cascade="all" class="BidirectionalRefIngPK" />
</class>
</hibernate-mapping>
When we try to load a BidirectionalRefIngPK, the underlying query invokes RelatedAuditExpression and since its not a foreign-key based one-to-one association the loading fails in method addToQuery of RelatedAuditExpression at line 52 (relatedEntity==null) with the following exception:
Code:
"This criterion can only be used on a property that is a relation to another property."
TO REPRODUCE
~~~~~~~~~~~~~
Please find a zip file attached which has four files:
- BidirectionalPrimaryAssociation.java (actual testng test case)
- BidirectionalRefEdPK.java (Entity 1)
- BidirectionalRefIngPK.java (Entity 2)
- mappings.hbm.xml
Please put the three java files in its package (org.hibernate.envers.test.integration.onetoone.bidirectional) and the mapping file in src/test/resources.
Now when you run envers tests you should see the failure.
Thanks for this great component !
--
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
12 years, 11 months
[Hibernate-JIRA] Created: (HHH-6689) DefaultMergeEventListener changes CheckNullability flag - not thread save
by John SMith (JIRA)
DefaultMergeEventListener changes CheckNullability flag - not thread save
-------------------------------------------------------------------------
Key: HHH-6689
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6689
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.5
Environment: Websphere Application Server 7.0, DB2, Windows Server, Hibernate 3.6.5
Reporter: John SMith
saveTransientEntity() method saves the CheckNullability setting, changes it using the getFactory().getSettings().setCheckNullability method, and does save processing. After save processing, the saved value is restored.
During load testing, we have had situations where the CheckNullability becomes set to TRUE and causes failures because of null checks.
It has been difficult to debug, but it appears that this is not thread safe - multiple threads accessing this method can change the value of this setting.
It can also be that a database error can cause an exception that will cause the checkNullability flan not to be reset.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 11 months
[Hibernate-JIRA] Created: (HHH-3414) fetch profiles
by Steve Ebersole (JIRA)
fetch profiles
--------------
Key: HHH-3414
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3414
Project: Hibernate3
Issue Type: New Feature
Components: core, metamodel
Reporter: Steve Ebersole
Assignee: Steve Ebersole
Fix For: 3.4
The concept of fetch profiles as we are discussing here is basically to allow users to dynamically affect the mapped fetching strategy for associations at runtime.
Consider the following example:
<class name="Person">
...
<set name="addresses" lazy="true" fetch="subselect" ...>
...
</set>
</class>
<class name="Address">
...
</class>
This follows the normal recommendation to map associations as lazy and use a dynamic fetching strategy (ala HQL/Criteria) to modify this lazy behavior at runtime.
The fetaure discussed here would allow the same behavior for loading as well:
<hibernate-mapping>
<fetch-profile name="person-details">
<fetch path="Person.addresses" style="join"/>
</fetch-profile>
</hibernate-mapping>
Or:
<hibernate-mapping>
<class name="Person">
...
<fetch-profile name="person-details">
<fetch path="addresses" style="join"/>
</fetch-profile>
<set name="addresses" lazy="true" fetch="subselect" ...>
...
</set>
</class>
</hibernate-mapping>
Now, doing:
session.enableFetchProfile( "person-details" ).get( Person.class, 1 )...
will load Person#1 as well as their addresses in a single joined query.
--
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
12 years, 11 months
[Hibernate-JIRA] Created: (HHH-5755) javax.persistence.criteria.Expression.as() is broken
by Artem Troitskiy (JIRA)
javax.persistence.criteria.Expression.as() is broken
----------------------------------------------------
Key: HHH-5755
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5755
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.6.0
Reporter: Artem Troitskiy
Priority: Minor
When I try to execute criteria query containing typecast to {{String}}
{noformat}
CriteriaQuery<Product> criteria = builder.createQuery( Product.class );
Root<Product> from = criteria.from( Product.class );
criteria.where(builder.like(from.get("partNumber").as(String.class), "1%"));
List<Product> result = em.createQuery( criteria ).getResultList();
{noformat}
I get the following exception
{quote}
org.hibernate.hql.ast.QuerySyntaxException: expecting CLOSE, found '(' near line 1, column 132 [select generatedAlias0 from org.hibernate.ejb.metamodel.Product as generatedAlias0 where cast(generatedAlias0.partNumber as varchar(255)) like :param0]
{quote}
As you can see, SQL type is used in HQL {{cast}} clause. It's caused by {{CriteriaQueryCompiler.RenderingContext.getCastType()}} that erroneously return SQL typename instead of Hibernate typename.
--
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
12 years, 11 months
[Hibernate-JIRA] Created: (ANN-721) ManyToOne Persisting Cascade in Embeddable
by Endre Jeges (JIRA)
ManyToOne Persisting Cascade in Embeddable
------------------------------------------
Key: ANN-721
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-721
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.1.GA
Environment: Java version:
java version "1.6.0_04"
Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)
Oracle Version:
Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
PL/SQL Release 9.2.0.8.0 - Production
"CORE 9.2.0.8.0 Production"
TNS for Linux: Version 9.2.0.8.0 - Production
NLSRTL Version 9.2.0.8.0 - Production
hibernate: 3.2.6.ga
hibernate-annotations: 3.3.1.ga
hibernate-commons-annotations: 3.3.0.ga
hibernate-entitymanager: 3.3.1.ga
Reporter: Endre Jeges
Attachments: pairTest.zip
Hello,
I have found something that is a bit strange. For @ManyToOne association properties in an @Embeddable class the cascade PERSIST, SAVE-UPDATE option is not working well (not sure for the other cascade types), if the entities associated with ManyToOne are transient. I have created a unit test to check it and I have it attached to this issue. It is a maven2 project, and needs Oracle to run it. If I save the associated entites, then everything works fine, also the data structure is created well.
I have checked the forums and found similar problems, maybe they can help more then my post:
http://forum.hibernate.org/viewtopic.php?t=965238
http://forum.hibernate.org/viewtopic.php?t=976534
http://forum.hibernate.org/viewtopic.php?t=978112
http://forum.hibernate.org/viewtopic.php?t=978138
http://forum.hibernate.org/viewtopic.php?t=983766
http://forum.hibernate.org/viewtopic.php?t=983780
http://forum.hibernate.org/viewtopic.php?t=983868
Details:
@Entity
class CodedPairHolder {
@Id
private Long id;
@Column(name = "CODE", nullable = false, unique = true, updatable = false, length = 256)
private String code;
@CollectionOfElements
@JoinTable(name = "CODED_PAIR_HOLDER_PAIR_SET", joinColumns = @JoinColumn(name = "CODED_PAIR_HOLDER_ID"))
private final Set<PersonPair> pairs = new HashSet<PersonPair>(0);
........ constructors getters equals hashCode
}
@Embeddable
class PersonPair {
@ManyToOne(optional = false, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
@Cascade( { org.hibernate.annotations.CascadeType.PERSIST, org.hibernate.annotations.CascadeType.MERGE, org.hibernate.annotations.CascadeType.REFRESH,
org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.REPLICATE, org.hibernate.annotations.CascadeType.EVICT })
@JoinColumn(name = "LEFT_PERSON_ID", nullable = false, updatable = false)
private Person left;
@ManyToOne(optional = false, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
@Cascade( { org.hibernate.annotations.CascadeType.PERSIST, org.hibernate.annotations.CascadeType.MERGE, org.hibernate.annotations.CascadeType.REFRESH,
org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.REPLICATE, org.hibernate.annotations.CascadeType.EVICT })
@JoinColumn(name = "RIGHT_PERSON_ID", nullable = false, updatable = false)
private Person right;
........ constructors getters equals hashCode
}
@Entity
class Person {
@Id
private Long id;
@Column(name = "NAME", nullable = false, unique = true, updatable = false, length = 256)
private String name;
........ constructors getters equals hashCode
}
The error message is:
org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: Person
Regards,
jeges
--
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
12 years, 11 months