[Hibernate-JIRA] Created: (HHH-3107) Error with sql generated for set of subclass A in a peer subclass B.
by Austin Mayberry (JIRA)
Error with sql generated for set of subclass A in a peer subclass B.
--------------------------------------------------------------------
Key: HHH-3107
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3107
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.6
Reporter: Austin Mayberry
A mapping such as the following contrived examples does not yield the expected results and causes and error:
<class name="com.foo.Foo1" table="FOO1">
<id
name="id"
type="java.lang.Integer"
column="ID"
>
<generator class="sequence" >
<param name="sequence">ID_SEQ</param>
</generator>
</id>
<discriminator column="FOO_TYPE_ID" type="java.lang.Integer"/>
<subclass name="com.foo.Foo2" discriminator-value="0">
<join table="FOO2">
<key column="ID"/>
<property
name="label"
type="java.lang.String"
column="LABEL"
not-null="true"
length="255"
/>
</join>
<subclass name="com.foo.BarOne" discriminator-value="1">
<set
name="barTwos"
inverse="true"
>
<key>
<column name="PARENT_ID" />
</key>
<one-to-many class="com.foo.BarTwo" />
</set>
</subclass>
<subclass name="com.foo.BarTwo" discriminator-value="2">
<join table="BAR">
<key column="ID"/>
<many-to-one
name="parent"
class="com.foo.BarOne"
not-null="true"
column="PARENT_ID"
/>
</join>
</subclass>
</subclass>
</class>
The sql created to populate the set "bartwos" looks like this looks like:
select
bartwos0_.PARENT_ID as PA3_1_,
bartwos0_.ID as ID1_1_,
bartwos0_.ID as ID1_52_0_,
bartwos0_.FOO_TYPE_ID as FO2_52_0_,
bartwos0_1_.LABEL as LABEL76_0_,
bartwos0_2_.PARENT_ID as PA2_87_0_
from FOO1 bartwos0_, FOO2 bartwos0_1_, BAR2 bartwos0_2_
where bartwos0_.ID=bartwos0_1_.ID
and bartwos0_.ID=bartwos0_2_.ID
and bartwos0_.PARENT_ID=?
And yields the following error message:
java.sql.SQLException: ORA-00904: "BARTWOS0_"."PARENT_ID: invalid identifier
The basic problem is that it should be looking for the property PARENT_ID on BAR2, but it is looking for it on FOO1.
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-3752) Error with sql generated for set of subclass A in a peer subclass B.
by Austin Mayberry (JIRA)
Error with sql generated for set of subclass A in a peer subclass B.
--------------------------------------------------------------------
Key: HHH-3752
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3752
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1, 3.3.0.SP1, 3.3.0.GA, 3.3.0.CR2, 3.3.0.CR1, 3.2.6, 3.2.5, 3.2.4.sp1, 3.2.4, 3.2.x, 3.3.x
Reporter: Austin Mayberry
A mapping such as the following contrived examples does not yield the expected results and causes and error:
<class name="com.foo.Foo1" table="FOO1">
<id
name="id"
type="java.lang.Integer"
column="ID"
>
<generator class="sequence" >
<param name="sequence">ID_SEQ</param>
</generator>
</id>
<discriminator column="FOO_TYPE_ID" type="java.lang.Integer"/>
<subclass name="com.foo.Foo2" discriminator-value="0">
<join table="FOO2">
<key column="ID"/>
<property
name="label"
type="java.lang.String"
column="LABEL"
not-null="true"
length="255"
/>
</join>
<subclass name="com.foo.BarOne" discriminator-value="1">
<set
name="barTwos"
inverse="true"
>
<key>
<column name="PARENT_ID" />
</key>
<one-to-many class="com.foo.BarTwo" />
</set>
</subclass>
<subclass name="com.foo.BarTwo" discriminator-value="2">
<join table="BAR">
<key column="ID"/>
<many-to-one
name="parent"
class="com.foo.BarOne"
not-null="true"
column="PARENT_ID"
/>
</join>
</subclass>
</subclass>
</class>
The sql created to populate the set "bartwos" looks like this looks like:
select
bartwos0_.PARENT_ID as PA3_1_,
bartwos0_.ID as ID1_1_,
bartwos0_.ID as ID1_52_0_,
bartwos0_.FOO_TYPE_ID as FO2_52_0_,
bartwos0_1_.LABEL as LABEL76_0_,
bartwos0_2_.PARENT_ID as PA2_87_0_
from FOO1 bartwos0_, FOO2 bartwos0_1_, BAR2 bartwos0_2_
where bartwos0_.ID=bartwos0_1_.ID
and bartwos0_.ID=bartwos0_2_.ID
and bartwos0_.PARENT_ID=?
And yields the following error message:
java.sql.SQLException: ORA-00904: "BARTWOS0_"."PARENT_ID: invalid identifier
The basic problem is that it should be looking for the property PARENT_ID on BAR2, but it is looking for it on FOO1.
I am refiling this bug because I originally only filed agains 3.2.4. It has been a year with no comments on it so I a resubmitting for all affected versions I have tried.
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-3748) foreign key attributed to wrong table when table for subclass with inheritance model is used
by Paul Pogonyshev (JIRA)
foreign key attributed to wrong table when table for subclass with inheritance model is used
--------------------------------------------------------------------------------------------
Key: HHH-3748
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3748
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1, 3.4
Environment: Tested with 3.3.1.GA + Oracle and 3.4 (trunk) + hsqldb.
Reporter: Paul Pogonyshev
Attachments: test.diff
When a collection of inherited objects (using table per subclass with discriminator model) is mapped, foreign key is always attributed to the base class table, not inherited class table. This means fields in inherited class tables are _unusable_ as keys for collections, or at least I don't see any way to use them.
This is a workaroundable issue for new databases (you could move the field to the base table, even if this is suboptimal), but a blocker for interfacing already existing database schemas.
I tried to create a testcase for this, attached is a diff against trunk. The test doesn't visibly fail, because I do not know how to check which table it references. However, you can see in ASTParserLoadingTest-output.txt:
create table DIBase (
id bigint generated by default as identity (start with 1),
type varchar(255) not null,
container bigint,
primary key (id)
)
create table DISubclass1 (
id bigint not null,
container bigint,
primary key (id)
)
I.e. field 'container' ends up in both base and derived class tables. Second is because of the 'many-to-one'. First is because foreign key from 'children' bag is attributed to a wrong table: instead, Hibernate should reuse the column in DISubclass1 table.
Might be related to issue 3500.
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-4761) Projection row count fails with MySQL causing paged results to fail
by Martijn Verburg (JIRA)
Projection row count fails with MySQL causing paged results to fail
-------------------------------------------------------------------
Key: HHH-4761
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4761
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.2
Environment: MySQL community 5.1.41 with latest J connector, running on Jboss 4.2.3.GA (Sun JDK 1.5.0_x), This case exists with MySQL, MySQL5 and MySQL5InnoDB dialects
Reporter: Martijn Verburg
Hi all
I have a piece of Java code that gets back a paged result set is as follows
// Lots of general criteria above this which generates the WHERE clause
..
..
criteria.setMaxResults(maxResults);
criteria.setFirstResult(firstResult);
criteria.addOrder(Order.desc("id"));
// Execute the actual search (**this works and brings back the expected list**)
List<WiretapEventHeader> wiretapResults = criteria.list();
// Now execute a std hibernate method to get the rowcount so we can page correctly
criteria.setProjection(Projections.rowCount());
Integer rowCount = 0;
List<Integer> rowCountList = criteria.list();
// BUG? We never go into this if case if we go beyond the first page
if (!rowCountList.isEmpty())
{
rowCount = rowCountList.get(0);
}
// Continuation of BUG? Always pass in 0 as rowCount when we go beyond the first page
return new PagedWiretapSearchResult(wiretapResults, rowCount, firstResult);
* The SQL it runs to perform a rowcount when listing the first page (which is successful) is:
select count(*) as y0_ from IkasanWiretap this_ where this_.ModuleName in (?, ?) order by this_.Id asc limit ?
* The SQL it runs to perform a rowcount when listing the subsequent pages (BUG? not successful) is:
select count(*) as y0_ from IkasanWiretap this_ where this_.ModuleName in (?, ?) order by this_.Id asc limit ?, ?
I simplified this down to the examples I gave the MySQL guys in http://bugs.mysql.com/bug.php?id=50005 and ran those from the MySQL query console, when providing the limit ?, ? case, you simply do not get back what I think are sensible results. In fact more often than not you get NULL list returned which causes the PagedWiretapSearchResult(wiretapResults, rowCount, firstResult) to execute with 0 rowCount which then returns a pagedResultSet with resultSize == 0
So I think Hibernate core needs to use alternative SQL to get the Projected rowcount from MySQL5
I've run the exact same code against Sybase without error.
Hope that all made sense, let me know if you need more details!
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-2584) PersistentMap.remove() incorrect on uninitialized, non-extra-lazy map
by Daniel Wellman (JIRA)
PersistentMap.remove() incorrect on uninitialized, non-extra-lazy map
---------------------------------------------------------------------
Key: HHH-2584
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2584
Project: Hibernate3
Issue Type: Patch
Components: core
Affects Versions: 3.2.3, 3.2.2, 3.2.1
Environment: Hibernate 3.2.3 ga, MySQL 5.0.24a, for Win32
Reporter: Daniel Wellman
Attachments: persistentmap_remove.patch
This problem is nearly identical to HHH-2476: PersistentMap.put() incorrect on uninitialized, non-extra-lazy map. remove() has the same problem. See also issue HHH-2142.
The write up for HHH-2476 was so concise that I will transform it here, substituting remove() for put().
---
Essentially, an uninitialized PersistentMap loses the first remove() into it if defined as non-extra-lazy.
The underlying cause is the code in PersistentMap#remove() which attempts to readElementByIndex(). In the case of non-extra-lazy, readElementByIndex() returns the UNKNOWN marker object which is supposed to be used to signal that the delegate map is now initialized and to remove the element directly from the map. Long story short, PersistentMap#remove() does not properly check the return value from readElementByIndex() and react accordingly.
--
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, 8 months