[Hibernate-JIRA] Created: (HHH-2617) Warning on tables with inheritance when table defaults are set in entity-mappings
by Stephen Todd (JIRA)
Warning on tables with inheritance when table defaults are set in entity-mappings
---------------------------------------------------------------------------------
Key: HHH-2617
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2617
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.2
Environment: Using Annotations
Reporter: Stephen Todd
Priority: Trivial
Attachments: inheritance-orm.xml, TestSingleTableInheritanceWarnings.java
The following warning message is logged when entity-mapping defaults are set and tables with inheritance are present:
Illegal use of @Table in a subclass of a SINGLE_TABLE hierarchy: class.name.Here
I attached a test case that recreates the problem. Basically, the error occurs when a resource contains persistence-unit-defaults. It appears that hibernate creates an @Table attribute for every registered entity when I think it should only do it for non-single table inheritance entities. Below is an example of the orm.xml
<entity-mappings>
<persistence-unit-metadata>
<persistence-unit-defaults>
<catalog>public</catalog>
</persistence-unit-defaults>
</persistence-unit-metadata>
<entity class="hibernatebugs.TestAnnotationWarnings$ParentEntity">
<inheritance strategy="SINGLE_TABLE"/>
</entity>
</entity-mappings>
Test requires EasyMock and Log4J.
--
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
18 years
[Hibernate-JIRA] Created: (HHH-2073) many-to-one join fetch with optional parent causing stray query to fire
by Adam Hardy (JIRA)
many-to-one join fetch with optional parent causing stray query to fire
-----------------------------------------------------------------------
Key: HHH-2073
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2073
Project: Hibernate3
Type: Bug
Reporter: Adam Hardy
Priority: Minor
Attachments: bugtest.zip
I have a call centre application which uses a mature database and is therefore pushing Hibernate to accomplish the mappings I need. The issue here is extra queries that Hibernate is firing where I set up the mapping to do a join in one hit.
I am fetching child objects which may or may not have a parent. The child's foreign key points to a non-primary key on the parent. This is not reflected by a foreign key constraint in the database (hence it allows child to have no parent).
If the child object has the foreign key 0 instead of null, which is the protocol in this database, then the parent which doesn't exist is not (& cannot) be instantiated, no problem, but then after processing the resultset, Hibernate fires off another query to fetch the parent that it could not find data for in the first query.
This is obviously unnecessary in this context and degrades the performance on large searches on this child.
I have classified it as minor since I suspect there may be work-arounds but I have not researched that yet.
I didn't know whether I could put the mapping XML in the query, so I have attached a simplistic testcase example that demonstrates the problem.
The following forum messages are relevant and the latter contains the mappings, which is easier than extracting them out of the testcase zip:
http://forum.hibernate.org/viewtopic.php?t=960522
http://forum.hibernate.org/viewtopic.php?t=964211
--
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
18 years
[Hibernate-JIRA] Created: (HHH-3110) JTATransaction could not find UserTransaction in JNDI when working with JOTM
by Felix von Delius (JIRA)
JTATransaction could not find UserTransaction in JNDI when working with JOTM
----------------------------------------------------------------------------
Key: HHH-3110
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3110
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.6
Environment: Hibernate 3.2.6, Oracle9i, jotm-2.0.10
Reporter: Felix von Delius
Priority: Critical
In our local (out-of-container) environment, we use JTA with JOTM as the JTA implementation.
It seems that the fix for HHH-1956 has this side effect, since I build a patched version of Hibernate-3.2.6 with the lazy initialization of hibernateTransaction commented out (lines 171-173 in JDBCContext.java).
Here is the relevant part of the stacktrace caused by the problem:
[ID:KxMaQ USER:\OPTIMMOSYS] 15:27:04,107 ERROR [JTATransaction] Could not find UserTransaction in JNDI
javax.naming.NameNotFoundException
at org.objectweb.carol.jndi.enc.java.CompNamingContext.lookupCtx(CompNamingContext.java:689)
at org.objectweb.carol.jndi.enc.java.CompNamingContext.lookup(CompNamingContext.java:179)
at org.objectweb.carol.jndi.enc.java.JavaURLContext.lookup(JavaURLContext.java:138)
at javax.naming.InitialContext.lookup(InitialContext.java:361)
at org.hibernate.transaction.JTATransaction.<init>(JTATransaction.java:60)
at org.hibernate.transaction.JTATransactionFactory.createTransaction(JTATransactionFactory.java:57)
at org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible(JDBCContext.java:172)
at org.hibernate.jdbc.JDBCContext.<init>(JDBCContext.java:76)
at org.hibernate.impl.SessionImpl.<init>(SessionImpl.java:213)
at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:473)
at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:497)
at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:505)
at com.ing.diba.mws.tcore.persistence.HibernateSessionSourceImpl.createPersistenceProvider(HibernateSessionSourceImpl.java:45)
Our configuration in this case contains:
hibernate.transaction.manager_lookup_class=org.hibernate.transaction.JOTMTransactionManagerLookup
--
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
18 years
[Hibernate-JIRA] Created: (HHH-2664) full join not working
by Fabio Tudone (JIRA)
full join not working
---------------------
Key: HHH-2664
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2664
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.4, 3.1.2
Environment: Any DB, tested on Windows
Reporter: Fabio Tudone
Attachments: test.jar
I get this error when trying to full join:
- an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: undefined join type 23
at org.hibernate.hql.ast.util.JoinProcessor.toHibernateJoinType(JoinProcessor.java:68)
at org.hibernate.hql.ast.HqlSqlWalker.setImpliedJoinType(HqlSqlWalker.java:433)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3157)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3067)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at com.finantix.test.Main.main(Main.java:63)
--
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
18 years, 1 month
[Hibernate-JIRA] Created: (HHH-2996) Allow expression in a @JoinColumn for a composite foreign key
by Darren Bell (JIRA)
Allow expression in a @JoinColumn for a composite foreign key
-------------------------------------------------------------
Key: HHH-2996
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2996
Project: Hibernate3
Issue Type: New Feature
Affects Versions: 3.2.5
Environment: hibernate 3.2.5, db2/400 v5r4
Reporter: Darren Bell
I am mapping our Mapics COM history with hibernate and have been pretty successful so far, but have hit a stumbling block.
There is a table in Mapics that stores history comments for many different other tables, hence each table has a different foreign key.
The table is outlined below for those that don't know Mapics ;)
COL_NO NAME COL_TYPE LENGTH DP NULL DFT DEFAULT DESCRIPTION
1 GAAENB NUMERIC 2 0 N Y 0 Company number
2 GAGGNB NUMERIC 6 0 N Y 0 Invoice number
3 GAHYNB DECIMAL 7 0 N Y 0 Invoice sequence
4 GAKBNB DECIMAL 5 0 N Y 0 Comment line sequence number
5 GAAKCD CHAR 3 N Y ' ' Language code
6 GAAAD9 CHAR 1 N Y ' ' Internal print only?
7 GAHDTX CHAR 25 N Y ' ' Comment line text
8 GAHXCD CHAR 5 N Y ' ' Comment user reference
9 GADCCD CHAR 1 N Y ' ' Internal header type
10 GACVNB CHAR 7 N Y ' ' Quote/order number
11 GAK4NB DECIMAL 7 0 N Y 0 Shipment header number
12 GAAFAD DECIMAL 3 0 N Y 0 Shipment consolidate seq
13 GALCNB DECIMAL 7 0 N Y 0 Ship release sequence
14 GAAASZ DECIMAL 5 0 N Y 0 Kit release sequence
15 GAAAD2 DECIMAL 7 0 N Y 0 Special charge sequence #
16 GAAD1N CHAR 1 N Y ' ' Text line print control
To get the comments from the shipment release we use the following:
@OneToMany()
@JoinColumns ({
@JoinColumn(name=HistoricalComment.Columns.COMPANY_NUMBER, referencedColumnName=ShipRelease.Columns.COMPANY_NUMBER),
@JoinColumn(name=HistoricalComment.Columns.INTERNAL_HEADER_TYPE, referencedColumnName=ShipRelease.Columns.INTERNAL_HEADER_TYPE),
@JoinColumn(name=HistoricalComment.Columns.ORDER_NUMBER, referencedColumnName=ShipRelease.Columns.ORDER_NUMBER),
@JoinColumn(name=HistoricalComment.Columns.SHIPMENT_HEADER_NUMBER, referencedColumnName=ShipRelease.Columns.SHIPMENT_HEADER_NUMBER),
@JoinColumn(name=HistoricalComment.Columns.SHIP_RELEASE_SEQUENCE, referencedColumnName=ShipRelease.Columns.SHIP_RELEASE_SEQUENCE),
@JoinColumn(name=HistoricalComment.Columns.KIT_RELEASE_SEQUENCE, referencedColumnName=ShipRelease.Columns.KIT_RELEASE_SEQUENCE)
})
@Sort(type=SortType.NATURAL)
private SortedSet<HistoricalComment> historicalComments;
Which works well, but to the the comments for the ship header the following is needed
@OneToMany()
@JoinColumns ({
@JoinColumn(name=HistoricalComment.Columns.COMPANY_NUMBER, referencedColumnName=ShipHeader.Columns.COMPANY_NUMBER),
@JoinColumn(name=HistoricalComment.Columns.INTERNAL_HEADER_TYPE, referencedColumnName=ShipHeader.Columns.INTERNAL_HEADER_TYPE),
@JoinColumn(name=HistoricalComment.Columns.ORDER_NUMBER, referencedColumnName=ShipHeader.Columns.ORDER_NUMBER),
@JoinColumn(name=HistoricalComment.Columns.SHIPMENT_HEADER_NUMBER, referencedColumnName=ShipHeader.Columns.SHIPMENT_HEADER_NUMBER)
})
@Sort(type=SortType.NATURAL)
private SortedSet<HistoricalComment> historicalComments;
As you can see there are two keys missing on the second one to many. This has the undesired effect of retriving all the comments for the entire shipment, whether they are related to a relase, the header itself, or charge codes.
Now, what i'm suggesting is to allow an expression for one of the join colums. The following would solve the problem.
@OneToMany()
@JoinColumns ({
@JoinColumn(name=HistoricalComment.Columns.COMPANY_NUMBER, referencedColumnName=ShipRelease.Columns.COMPANY_NUMBER),
@JoinColumn(name=HistoricalComment.Columns.INTERNAL_HEADER_TYPE, referencedColumnName=ShipRelease.Columns.INTERNAL_HEADER_TYPE),
@JoinColumn(name=HistoricalComment.Columns.ORDER_NUMBER, referencedColumnName=ShipRelease.Columns.ORDER_NUMBER),
@JoinColumn(name=HistoricalComment.Columns.SHIPMENT_HEADER_NUMBER, referencedColumnName=ShipRelease.Columns.SHIPMENT_HEADER_NUMBER),
@JoinColumn(name=HistoricalComment.Columns.SHIP_RELEASE_SEQUENCE, expression=":shipReleaseSequence > 0"),
@JoinColumn(name=HistoricalComment.Columns.KIT_RELEASE_SEQUENCE, expression=":kitReleaseSequence = 0")
})
This would put the expressions into the join clause.
What do you think? Have i explained this well enough?
--
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
18 years, 1 month
[Hibernate-JIRA] Created: (ANN-689) @JoinColumn not quoted for Oracle dialect
by Earnie Dyke (JIRA)
@JoinColumn not quoted for Oracle dialect
-----------------------------------------
Key: ANN-689
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-689
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.2.1
Environment: Oracle 10g XE
Reporter: Earnie Dyke
Within an @Entity I have the following:
@ManyToOne(cascase = {}, fetch = FecthType.Lazy)
@JoinColumn(name = "`PresentationId`") // Notice the backticks
public Presentation getPresentation() {
return this.presentation;
}
the generated SQL for a load is:
select ... from PRESENTATION presentati0_ left outer join CSESSION csessions1_ on presentati0_."Id"=csessions1_.PresentationId where ...
Notice that PresentationId in csessions1_.PresentationId is NOT quoted. This causes an exception from Oracle:
java.sql.SQLException: ORA-00904: "CSESSIONS1_"."PRESENTATIONID": invalid identifier.
I added the backticks to all @Column annotations and they work. Also PresentationId is not quoted in the SELECT list either.
Earnie!
--
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
18 years, 1 month