[Hibernate-JIRA] Created: (HHH-5432) Mapping gets confused if superclasses are in different packages.
by Pierce Wetter (JIRA)
Mapping gets confused if superclasses are in different packages.
-----------------------------------------------------------------
Key: HHH-5432
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5432
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.6.0.Beta1, 3.5.4, 3.5.3, 3.5.2, 3.5.1, 3.5.0-Final
Reporter: Pierce Wetter
Let's say because you use a mixture of generated and customized code, so that most of your classes are split into a generated superclass in one package, and a subclass that's where you put custom code. If you put the generated code in a different package, Hibernate will have issues with the mapping, such that it will miss the superclasses. This becomes obvious if you generate the metamodel, because it will omit "extends superclass" from the model.
i.e.:
com.example.jpa.generated
com.example.jpa.custom
public class com.example.jpa.custom.RootClass.java
public class com.example.jpa.generated.FirstClassGen.java extends RootClass
public class com.example.jpa.custom.FirstClass.java extends FirstClassGen
public class com.example.jpa.generated.SecondClassGen.java extends FirstClass
public class com.example.jpa.custom.SecondClass.java extends SecondGlassGen
This causes Hibernate to get confused. However, if everything is in the same package, things are ok, the superclasses are correctly mapped.
--
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, 5 months
[Hibernate-JIRA] Created: (HHH-5091) Unidirectional One-To-Many relationship with foreign key mapping doesn't work
by Juergen Zimmermann (JIRA)
Unidirectional One-To-Many relationship with foreign key mapping doesn't work
-----------------------------------------------------------------------------
Key: HHH-5091
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5091
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.5.0-Final
Reporter: Juergen Zimmermann
I've the following 2 tables (in PostgreSQL) in a one-to-many relationship with foreign key mapping:
CREATE TABLE bestellung(
b_id BIGSERIAL NOT NULL PRIMARY KEY,
version INTEGER DEFAULT 0,
kunde_fk BIGINT NOT NULL REFERENCES kunde(k_id)
);
CREATE TABLE bestellposition(
bp_id BIGSERIAL NOT NULL PRIMARY KEY,
version INTEGER DEFAULT 0,
artikel_fk BIGINT NOT NULL REFERENCES artikel(a_id),
anzahl SMALLINT NOT NULL,
bestellung_fk BIGINT NOT NULL REFERENCES bestellung(b_id)
);
Now the 2 JPA entity classes:
// owner class
@Entity
@Table(name="bestellung")
public class Bestellung implements java.io.Serializable {
@Id
@GeneratedValue(generator="bestellung_sequence_name")
@SequenceGenerator(name="bestellung_sequence_name", sequenceName="bestellung_b_id_seq", allocationSize=1)
@Column(name="b_id", nullable=false)
private Long id = null;
@Version
private int version = 0;
// bidirectional
@ManyToOne(optional=false)
@JoinColumn(name="kunde_fk")
@NotNull(message="{bestellverwaltung.bestellung.kunde.notNull}")
private Kunde kunde;
// unidirectional and cascading persist
@OneToMany(fetch=EAGER, cascade={PERSIST, REMOVE}, orphanRemoval=true)
@JoinColumn(name="bestellung_fk")
@OrderBy("id ASC")
@NotEmpty(message="{bestellverwaltung.bestellung.bestellpositionen.notEmpty}")
private List<Bestellposition> bestellpositionen;
}
// dependant class
@Entity
@Table(name="bestellposition")
public class Bestellposition implements java.io.Serializable {
@Id
@GeneratedValue(generator="bestellposition_sequence_name")
@SequenceGenerator(name="bestellposition_sequence_name", sequenceName="bestellposition_bp_id_seq", allocationSize=1)
@Column(name="bp_id", nullable=false)
private Long id = null;
@Version
private int version = 0;
@Column(nullable=false)
@Min(value=ANZAHL_MIN, message="{bestellverwaltung.bestellposition.anzahl.min}")
private short anzahl = 1;
@ManyToOne(optional=false)
@JoinColumn(name="artikel_fk")
@NotNull(message="{bestellverwaltung.bestellposition.artikel.notNull}")
private Artikel artikel;
}
Inside the owner class the dependent class is declared with cascade=PERSIST (see above). When I try to create a persistent entity of class Bestellung (owner class) then the generated SQL statement is wrong because the foreign key ("bestellung_fk") for the owner record is missing.
insert into bestellposition(anzahl, artikel_fk, version, bp_id)
values(?, ?, ?, ?)
--
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, 5 months
[Hibernate-JIRA] Created: (HHH-3478) @NaturalId queries not flushed from cache using EntityManager.remove(); exception results from query
by Elias Ross (JIRA)
@NaturalId queries not flushed from cache using EntityManager.remove(); exception results from query
----------------------------------------------------------------------------------------------------
Key: HHH-3478
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3478
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.3.0.SP1
Environment: Java 1.5, Maven dependencies:
[INFO] (root)
[INFO] | \- org.hibernate:hibernate-validator:jar:3.1.0.GA:compile
[INFO] +- commons-codec:commons-codec:jar:1.3:compile
[INFO] +- javax.persistence:persistence-api:jar:1.0:compile
[INFO] +- org.hibernate:hibernate-core:jar:3.3.0.SP1:compile
[INFO] | +- antlr:antlr:jar:2.7.6:compile
[INFO] | +- commons-collections:commons-collections:jar:3.1:compile
[INFO] | \- dom4j:dom4j:jar:1.6.1:compile
[INFO] | \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] +- org.hibernate:hibernate-annotations:jar:3.4.0.GA:compile
[INFO] | \- org.hibernate:ejb3-persistence:jar:1.0.2.GA:compile
[INFO] +- org.hibernate:hibernate-commons-annotations:jar:3.3.0.ga:compile
[INFO] | \- org.hibernate:hibernate:jar:3.2.1.ga:compile
[INFO] | +- net.sf.ehcache:ehcache:jar:1.2.3:compile
[INFO] | +- asm:asm-attrs:jar:1.5.3:compile
[INFO] | +- cglib:cglib:jar:2.1_3:compile
[INFO] | \- asm:asm:jar:1.5.3:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:3.4.0.GA:compile
[INFO] | \- javassist:javassist:jar:3.4.GA:compile
[INFO] +- javax.transaction:jta:jar:1.0.1B:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.5.2:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.5.2:compile
[INFO] +- hsqldb:hsqldb:jar:1.8.0.10:test
[INFO] \- junit:junit:jar:4.4:test
Reporter: Elias Ross
Attachments: Dummy.java, DummyTest.java, persistence.xml
See attached test case and entity.
Current Result:
javax.persistence.EntityNotFoundException: Unable to find com.autodesk.lbs.cs.Dummy with id 1
at org.hibernate.ejb.Ejb3Configuration$Ejb3EntityNotFoundDelegate.handleEntityNotFound(Ejb3Configuration.java:113)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:171)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:223)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:126)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:905)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:873)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:590)
at org.hibernate.type.ManyToOneType.assemble(ManyToOneType.java:219)
at org.hibernate.cache.StandardQueryCache.get(StandardQueryCache.java:155)
at org.hibernate.loader.Loader.getResultFromQueryCache(Loader.java:2184)
at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2147)
at org.hibernate.loader.Loader.list(Loader.java:2117)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1596)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:328)
at com.autodesk.lbs.cs.DummyTest.naturalKeyCachedQuery(DummyTest.java:69)
at com.autodesk.lbs.cs.DummyTest.naturalKeyCachedQuery(DummyTest.java:61)
at com.autodesk.lbs.cs.DummyTest.testQuery(DummyTest.java:49)
It's expected that a cache invalidation occurs with an entity's natural key when it is removed.
I'll investigate a solution.
--
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, 5 months
[Hibernate-JIRA] Created: (JPA-5) Using JPA, order of database columns are reverse of how they appear in XML metadata!
by Colbert Philippe (JIRA)
Using JPA, order of database columns are reverse of how they appear in XML metadata!
------------------------------------------------------------------------------------
Key: JPA-5
URL: http://opensource.atlassian.com/projects/hibernate/browse/JPA-5
Project: Java Persistence API
Issue Type: Bug
Environment: Testing with Windows 7 but this bug should appear everywhere.
Reporter: Colbert Philippe
Priority: Minor
It's important to have control over the order columns of each generated table. In the past, I used Hibernate native, now I upgrated to JPA to maintain compatibility with Cloud systems. With Hibernate native, the order of the column was the same as they appear in the XML metadata.
However with JPA, it's a different story. The order of the generated columns is the reverse of how they appear in the JPA XML metadata. That's not right if you are trying interface with legacy systems and the database system is made up on legacy databases.
My bug report has two aspects to it.
1) First spact is that the JPA XML schema (http://java.sun.com/xml/ns/persistence/orm_2_0.xsd) is not flexible and has strict rules as to how to order elements inside a Java class. For instance: The attributes always come first followed by associations. In other word they used SEQUENCE in the schema instead of using ALTERNATIVES.
This apparent error is part of the standard and not the fault of the Hibernate.
2) Second aspect is that even within attributes in the XML metadata, the order is not respected. In fact it is reversed to what is specified in the XML metadata file, which is very strange. That's a definitely an error from Hibernate and should be fixed.
--
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, 5 months
[Hibernate-JIRA] Commented: (HHH-1928) order-by mapping for collections overrides order by in Criteria
by Kai Moritz (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1928?page=c... ]
Kai Moritz commented on HHH-1928:
---------------------------------
This bug is still open in 3.2.6.ga!
Is it resolved in 3.5?
> order-by mapping for collections overrides order by in Criteria
> ---------------------------------------------------------------
>
> Key: HHH-1928
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1928
> Project: Hibernate Core
> Issue Type: Bug
> Components: query-criteria
> Affects Versions: 3.2.0.cr3
> Reporter: Nguyen Hau Giang
> Attachments: testcase.zip
>
>
> relating to:
> HHH-594(order-by mapping for collections overrides order by in HQL)
> HHH-484(order-by not applied to collections fetched by OuterJoinLoader)
> Mapping(pseudo code):
> <class name="Master">
> <id name="id" />
> <set name="details" order-by="DISP_NO">
> <one-to-many class="Detail" />
> </set>
> </class>
> <class name="Detail">
> <id name="id" />
> <property name="dispNo" />
> <many-to-one name="master" class="Master" />
> </class>
> Same problem as in HHH-594, but instead of querying by HQL, when query by Criteria using join-fetch:
> session.createCriteria(Master.class)//
> .setFetchMode("details", FetchMode.JOIN)//
> .addOrder(Order.asc("id"))//
> .list();
> order-by mapping for collection overrides order by in Criteria:
> from
> Master this_
> left outer join
> Detail details2_
> on this_.id=details2_.ID
> order by
> details2_.DISP_NO,
> this_.id asc
> or when creating left-join alias:
> session.createCriteria(Master.class)//
> .createAlias("details", "D", Criteria.LEFT_JOIN)//
> .addOrder(Order.asc("id"))//
> .list();
> generated SQL:
> from
> Master this_
> left outer join
> Detail d1_
> on this_.id=d1_.ID
> order by
> d1_.DISP_NO,
> this_.id asc
> The order property specified in Criteria should be prior to order of collection mapping.
> I think this problem should be fixed as with HQL in HHH-594.
> For details, please see attached test case.
--
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, 5 months