[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, 6 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, 6 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, 6 months
[Hibernate-JIRA] Created: (HHH-3030) NullPointerException happens in versioning
by John (JIRA)
NullPointerException happens in versioning
------------------------------------------
Key: HHH-3030
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3030
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.5
Environment: any
Reporter: John
Priority: Minor
Here is the stack trace:
java.lang.NullPointerException
at org.hibernate.type.IntegerType.next(IntegerType.java:59)
at org.hibernate.engine.Versioning.increment(Versioning.java:25)
at org.hibernate.event.def.DefaultFlushEntityEventListener.getNextVersion(DefaultFlushEntityEventListener.java:358)
at org.hibernate.event.def.DefaultFlushEntityEventListener.scheduleUpdate(DefaultFlushEntityEventListener.java:250)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:121)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:196)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:969)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1114)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
......
The code is:
public Object next(Object current, SessionImplementor session) {
return new Integer( ( (Integer) current ).intValue() + 1 );
}
Should there be a null checking for the object "current"?
--
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, 6 months
[Hibernate-JIRA] Created: (HHH-3349) SequenceStyleGenerator generates strange IDs for PostgreSQL database
by Adam Wozniak (JIRA)
SequenceStyleGenerator generates strange IDs for PostgreSQL database
--------------------------------------------------------------------
Key: HHH-3349
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3349
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.6
Environment: hibernate-3.2.6.ga, hibernate-annotations-3.3.1.GA, hibernate-entitymanager-3.3.2.GA, hibernate-validator-3.0.0.GA, PostgreSQL 8.3.1 on Windows box. Sun Java 6 (Win32 on Vista 32 bits).
Reporter: Adam Wozniak
Hello
I've got a standalone application using environment:
* PostgreSQL 8.3.1 (Win 32)
* hibernate-3.2.6.ga
* hibernate-annotations-3.3.1.GA
* hibernate-entitymanager-3.3.2.GA
* hibernate-validator-3.0.0.GA
I've got a PostgreSQL database sequence:
CREATE SEQUENCE t_seq
INCREMENT 10
MINVALUE 1
MAXVALUE 999999999999999999
START 11;
My entity:
@Entity
@Table(name = "T")
@org.hibernate.annotations.Entity(dynamicUpdate=true, dynamicInsert=true)
public class T
{
private long id;
@Id
@Column(unique = true, nullable = false, precision = 18, scale = 0)
@GeneratedValue(generator = "t_generator")
@GenericGenerator( name = "t_generator",
strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
parameters = {
@Parameter(name = "sequence_name", value = "T_SEQ")
, @Parameter(name = "increment_size", value = "10")
, @Parameter(name = "optimizer", value = "pooled")
}
)
public long getId()
{
return id;
}
public void setId(long id)
{
this.id = id;
}
}
And my test application to recreate this issue:
for(int i = 0; i < 11; i++)
{
if(i == 0 || i == 10)
System.out.println("Database hit to sequence will be performed.");
T t = new T();
em.persist(t);
}
Reading this Steve Ebersole description ( http://blog.hibernate.org/2082.lace#comments ) I would expect, that I will get the following IDs:
11
12
13
14
15
16
17
18
19
20
21
But Hibernate generates:
101
102
103
104
105
106
107
108
109
110
111
Is it something wrong with my code? Or this is a issue in Hibernate?
Note please, that on the same page ( http://blog.hibernate.org/2082.lace#comments ) other person claims that it doesn't work for his configuration based on PostgreSQL.
You will find my log4j output for my test application on the end of my email.
Regards,
Adam Wozniak
Piece of my log4j output:
2008-06-17 20:20:38,198 [main] DEBUG () SessionImpl: opened session at timestamp: 12137268381
2008-06-17 20:20:38,200 [main] DEBUG () JDBCTransaction: begin
2008-06-17 20:20:38,200 [main] DEBUG () ConnectionManager: opening JDBC connection
2008-06-17 20:20:38,200 [main] DEBUG () BasicResourcePool: trace com.mchange.v2.resourcepool.BasicResourcePool@104a4b6 [managed: 1, unused: 0, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@b206e9)
2008-06-17 20:20:38,202 [main] DEBUG () JDBCTransaction: current autocommit status: true
2008-06-17 20:20:38,202 [main] DEBUG () JDBCTransaction: disabling autocommit
2008-06-17 20:20:38,202 [main] DEBUG () JDBCContext: after transaction begin
Database hit to sequence will be performed.
2008-06-17 20:20:39,467 [main] DEBUG () IdentifierValue: id unsaved-value: 0
2008-06-17 20:20:39,469 [main] DEBUG () AbstractSaveEventListener: transient instance of: net.cellbell.model.T
2008-06-17 20:20:39,469 [main] DEBUG () DefaultPersistEventListener: saving transient instance
2008-06-17 20:20:39,472 [main] DEBUG () AbstractBatcher: about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2008-06-17 20:20:39,479 [main] DEBUG () AbstractBatcher:
select
nextval ('T_SEQ')
Hibernate:
select
nextval ('T_SEQ')
2008-06-17 20:20:39,480 [main] DEBUG () AbstractBatcher: preparing statement
2008-06-17 20:20:39,489 [main] DEBUG () GooGooStatementCache: cxnStmtMgr.statementSet( org.postgresql.jdbc4.Jdbc4Connection@1df3082 ).size(): 1
2008-06-17 20:20:39,489 [main] DEBUG () GooGooStatementCache: checkoutStatement: com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 1; checked out: 1; num connections: 1; num keys: 1
2008-06-17 20:20:39,506 [main] DEBUG () SequenceStructure$1: Sequence identifier generated: 11
2008-06-17 20:20:39,506 [main] DEBUG () AbstractBatcher: about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2008-06-17 20:20:39,507 [main] DEBUG () AbstractBatcher: closing statement
2008-06-17 20:20:39,507 [main] DEBUG () GooGooStatementCache: checkinStatement(): com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 1; checked out: 0; num connections: 1; num keys: 1
2008-06-17 20:20:39,508 [main] DEBUG () AbstractSaveEventListener: generated identifier: 101, using strategy: org.hibernate.id.enhanced.SequenceStyleGenerator
2008-06-17 20:20:39,513 [main] DEBUG () AbstractSaveEventListener: saving [net.cellbell.model.T#101]
2008-06-17 20:20:39,530 [main] DEBUG () IdentifierValue: id unsaved-value: 0
2008-06-17 20:20:39,530 [main] DEBUG () AbstractSaveEventListener: transient instance of: net.cellbell.model.T
2008-06-17 20:20:39,530 [main] DEBUG () DefaultPersistEventListener: saving transient instance
2008-06-17 20:20:39,530 [main] DEBUG () AbstractSaveEventListener: generated identifier: 102, using strategy: org.hibernate.id.enhanced.SequenceStyleGenerator
2008-06-17 20:20:39,531 [main] DEBUG () AbstractSaveEventListener: saving [net.cellbell.model.T#102]
2008-06-17 20:20:39,531 [main] DEBUG () IdentifierValue: id unsaved-value: 0
2008-06-17 20:20:39,531 [main] DEBUG () AbstractSaveEventListener: transient instance of: net.cellbell.model.T
2008-06-17 20:20:39,531 [main] DEBUG () DefaultPersistEventListener: saving transient instance
2008-06-17 20:20:39,532 [main] DEBUG () AbstractSaveEventListener: generated identifier: 103, using strategy: org.hibernate.id.enhanced.SequenceStyleGenerator
2008-06-17 20:20:39,532 [main] DEBUG () AbstractSaveEventListener: saving [net.cellbell.model.T#103]
2008-06-17 20:20:39,533 [main] DEBUG () IdentifierValue: id unsaved-value: 0
2008-06-17 20:20:39,533 [main] DEBUG () AbstractSaveEventListener: transient instance of: net.cellbell.model.T
2008-06-17 20:20:39,533 [main] DEBUG () DefaultPersistEventListener: saving transient instance
2008-06-17 20:20:39,533 [main] DEBUG () AbstractSaveEventListener: generated identifier: 104, using strategy: org.hibernate.id.enhanced.SequenceStyleGenerator
2008-06-17 20:20:39,534 [main] DEBUG () AbstractSaveEventListener: saving [net.cellbell.model.T#104]
2008-06-17 20:20:39,534 [main] DEBUG () IdentifierValue: id unsaved-value: 0
2008-06-17 20:20:39,534 [main] DEBUG () AbstractSaveEventListener: transient instance of: net.cellbell.model.T
2008-06-17 20:20:39,534 [main] DEBUG () DefaultPersistEventListener: saving transient instance
2008-06-17 20:20:39,534 [main] DEBUG () AbstractSaveEventListener: generated identifier: 105, using strategy: org.hibernate.id.enhanced.SequenceStyleGenerator
2008-06-17 20:20:39,535 [main] DEBUG () AbstractSaveEventListener: saving [net.cellbell.model.T#105]
2008-06-17 20:20:39,535 [main] DEBUG () IdentifierValue: id unsaved-value: 0
2008-06-17 20:20:39,535 [main] DEBUG () AbstractSaveEventListener: transient instance of: net.cellbell.model.T
2008-06-17 20:20:39,535 [main] DEBUG () DefaultPersistEventListener: saving transient instance
2008-06-17 20:20:39,536 [main] DEBUG () AbstractSaveEventListener: generated identifier: 106, using strategy: org.hibernate.id.enhanced.SequenceStyleGenerator
2008-06-17 20:20:39,536 [main] DEBUG () AbstractSaveEventListener: saving [net.cellbell.model.T#106]
2008-06-17 20:20:39,537 [main] DEBUG () IdentifierValue: id unsaved-value: 0
2008-06-17 20:20:39,537 [main] DEBUG () AbstractSaveEventListener: transient instance of: net.cellbell.model.T
2008-06-17 20:20:39,537 [main] DEBUG () DefaultPersistEventListener: saving transient instance
2008-06-17 20:20:39,537 [main] DEBUG () AbstractSaveEventListener: generated identifier: 107, using strategy: org.hibernate.id.enhanced.SequenceStyleGenerator
2008-06-17 20:20:39,537 [main] DEBUG () AbstractSaveEventListener: saving [net.cellbell.model.T#107]
2008-06-17 20:20:39,538 [main] DEBUG () IdentifierValue: id unsaved-value: 0
2008-06-17 20:20:39,538 [main] DEBUG () AbstractSaveEventListener: transient instance of: net.cellbell.model.T
2008-06-17 20:20:39,538 [main] DEBUG () DefaultPersistEventListener: saving transient instance
2008-06-17 20:20:39,538 [main] DEBUG () AbstractSaveEventListener: generated identifier: 108, using strategy: org.hibernate.id.enhanced.SequenceStyleGenerator
2008-06-17 20:20:39,539 [main] DEBUG () AbstractSaveEventListener: saving [net.cellbell.model.T#108]
2008-06-17 20:20:39,539 [main] DEBUG () IdentifierValue: id unsaved-value: 0
2008-06-17 20:20:39,539 [main] DEBUG () AbstractSaveEventListener: transient instance of: net.cellbell.model.T
2008-06-17 20:20:39,539 [main] DEBUG () DefaultPersistEventListener: saving transient instance
2008-06-17 20:20:39,539 [main] DEBUG () AbstractSaveEventListener: generated identifier: 109, using strategy: org.hibernate.id.enhanced.SequenceStyleGenerator
2008-06-17 20:20:39,540 [main] DEBUG () AbstractSaveEventListener: saving [net.cellbell.model.T#109]
2008-06-17 20:20:39,541 [main] DEBUG () IdentifierValue: id unsaved-value: 0
2008-06-17 20:20:39,541 [main] DEBUG () AbstractSaveEventListener: transient instance of: net.cellbell.model.T
2008-06-17 20:20:39,541 [main] DEBUG () DefaultPersistEventListener: saving transient instance
2008-06-17 20:20:39,541 [main] DEBUG () AbstractSaveEventListener: generated identifier: 110, using strategy: org.hibernate.id.enhanced.SequenceStyleGenerator
2008-06-17 20:20:39,541 [main] DEBUG () AbstractSaveEventListener: saving [net.cellbell.model.T#110]
Database hit to sequence will be performed.
2008-06-17 20:20:40,912 [main] DEBUG () IdentifierValue: id unsaved-value: 0
2008-06-17 20:20:40,912 [main] DEBUG () AbstractSaveEventListener: transient instance of: net.cellbell.model.T
2008-06-17 20:20:40,913 [main] DEBUG () DefaultPersistEventListener: saving transient instance
2008-06-17 20:20:40,913 [main] DEBUG () AbstractBatcher: about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2008-06-17 20:20:40,913 [main] DEBUG () AbstractBatcher:
select
nextval ('T_SEQ')
Hibernate:
select
nextval ('T_SEQ')
2008-06-17 20:20:40,914 [main] DEBUG () AbstractBatcher: preparing statement
2008-06-17 20:20:40,914 [main] DEBUG () GooGooStatementCache: com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache ----> CACHE HIT
2008-06-17 20:20:40,914 [main] DEBUG () GooGooStatementCache: checkoutStatement: com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 1; checked out: 1; num connections: 1; num keys: 1
2008-06-17 20:20:40,917 [main] DEBUG () SequenceStructure$1: Sequence identifier generated: 21
2008-06-17 20:20:40,917 [main] DEBUG () AbstractBatcher: about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2008-06-17 20:20:40,917 [main] DEBUG () AbstractBatcher: closing statement
2008-06-17 20:20:40,917 [main] DEBUG () GooGooStatementCache: checkinStatement(): com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 1; checked out: 0; num connections: 1; num keys: 1
2008-06-17 20:20:40,918 [main] DEBUG () AbstractSaveEventListener: generated identifier: 111, using strategy: org.hibernate.id.enhanced.SequenceStyleGenerator
2008-06-17 20:20:40,918 [main] DEBUG () AbstractSaveEventListener: saving [net.cellbell.model.T#111]
2008-06-17 20:20:40,919 [main] DEBUG () JDBCTransaction: commit
2008-06-17 20:20:40,919 [main] DEBUG () SessionImpl: automatically flushing session
2008-06-17 20:20:40,922 [main] DEBUG () AbstractFlushingEventListener: flushing session
2008-06-17 20:20:40,923 [main] DEBUG () AbstractFlushingEventListener: processing flush-time cascades
2008-06-17 20:20:40,924 [main] DEBUG () Cascade: processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,925 [main] DEBUG () Cascade: done processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,925 [main] DEBUG () Cascade: processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,925 [main] DEBUG () Cascade: done processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,926 [main] DEBUG () Cascade: processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,927 [main] DEBUG () Cascade: done processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,927 [main] DEBUG () Cascade: processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,927 [main] DEBUG () Cascade: done processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,927 [main] DEBUG () Cascade: processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,929 [main] DEBUG () Cascade: done processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,929 [main] DEBUG () Cascade: processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,929 [main] DEBUG () Cascade: done processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,929 [main] DEBUG () Cascade: processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,929 [main] DEBUG () Cascade: done processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,930 [main] DEBUG () Cascade: processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,930 [main] DEBUG () Cascade: done processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,930 [main] DEBUG () Cascade: processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,930 [main] DEBUG () Cascade: done processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,931 [main] DEBUG () Cascade: processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,932 [main] DEBUG () Cascade: done processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,932 [main] DEBUG () Cascade: processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,932 [main] DEBUG () Cascade: done processing cascade ACTION_PERSIST_ON_FLUSH for: net.cellbell.model.T
2008-06-17 20:20:40,932 [main] DEBUG () AbstractFlushingEventListener: dirty checking collections
2008-06-17 20:20:40,933 [main] DEBUG () AbstractFlushingEventListener: Flushing entities and processing referenced collections
2008-06-17 20:20:40,939 [main] DEBUG () AbstractFlushingEventListener: Processing unreferenced collections
2008-06-17 20:20:40,939 [main] DEBUG () AbstractFlushingEventListener: Scheduling collection removes/(re)creates/updates
2008-06-17 20:20:40,940 [main] DEBUG () AbstractFlushingEventListener: Flushed: 11 insertions, 0 updates, 0 deletions to 11 objects
2008-06-17 20:20:40,940 [main] DEBUG () AbstractFlushingEventListener: Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2008-06-17 20:20:40,942 [main] DEBUG () Printer: listing entities:
2008-06-17 20:20:40,942 [main] DEBUG () Printer: net.cellbell.model.T{id=105}
2008-06-17 20:20:40,943 [main] DEBUG () Printer: net.cellbell.model.T{id=104}
2008-06-17 20:20:40,943 [main] DEBUG () Printer: net.cellbell.model.T{id=107}
2008-06-17 20:20:40,943 [main] DEBUG () Printer: net.cellbell.model.T{id=106}
2008-06-17 20:20:40,945 [main] DEBUG () Printer: net.cellbell.model.T{id=101}
2008-06-17 20:20:40,945 [main] DEBUG () Printer: net.cellbell.model.T{id=103}
2008-06-17 20:20:40,945 [main] DEBUG () Printer: net.cellbell.model.T{id=102}
2008-06-17 20:20:40,945 [main] DEBUG () Printer: net.cellbell.model.T{id=109}
2008-06-17 20:20:40,945 [main] DEBUG () Printer: net.cellbell.model.T{id=108}
2008-06-17 20:20:40,946 [main] DEBUG () Printer: net.cellbell.model.T{id=111}
2008-06-17 20:20:40,946 [main] DEBUG () Printer: net.cellbell.model.T{id=110}
2008-06-17 20:20:40,946 [main] DEBUG () AbstractFlushingEventListener: executing flush
2008-06-17 20:20:40,947 [main] DEBUG () ConnectionManager: registering flush begin
2008-06-17 20:20:40,951 [main] DEBUG () AbstractEntityPersister: Inserting entity: [net.cellbell.model.T#101]
2008-06-17 20:20:40,956 [main] DEBUG () AbstractBatcher: about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2008-06-17 20:20:40,957 [main] DEBUG () AbstractBatcher:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
Hibernate:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
2008-06-17 20:20:40,957 [main] DEBUG () AbstractBatcher: preparing statement
2008-06-17 20:20:40,957 [main] DEBUG () GooGooStatementCache: cxnStmtMgr.statementSet( org.postgresql.jdbc4.Jdbc4Connection@1df3082 ).size(): 2
2008-06-17 20:20:40,959 [main] DEBUG () GooGooStatementCache: checkoutStatement: com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 2; checked out: 1; num connections: 1; num keys: 2
2008-06-17 20:20:40,959 [main] DEBUG () AbstractEntityPersister: Dehydrating entity: [net.cellbell.model.T#101]
2008-06-17 20:20:40,960 [main] DEBUG () NullableType: binding '101' to parameter: 1
2008-06-17 20:20:40,964 [main] DEBUG () AbstractEntityPersister: Inserting entity: [net.cellbell.model.T#102]
2008-06-17 20:20:40,965 [main] DEBUG () AbstractBatcher: reusing prepared statement
2008-06-17 20:20:40,965 [main] DEBUG () AbstractBatcher:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
Hibernate:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
2008-06-17 20:20:40,965 [main] DEBUG () AbstractEntityPersister: Dehydrating entity: [net.cellbell.model.T#102]
2008-06-17 20:20:40,967 [main] DEBUG () NullableType: binding '102' to parameter: 1
2008-06-17 20:20:40,967 [main] DEBUG () AbstractEntityPersister: Inserting entity: [net.cellbell.model.T#103]
2008-06-17 20:20:40,967 [main] DEBUG () AbstractBatcher: reusing prepared statement
2008-06-17 20:20:40,968 [main] DEBUG () AbstractBatcher:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
Hibernate:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
2008-06-17 20:20:40,968 [main] DEBUG () AbstractEntityPersister: Dehydrating entity: [net.cellbell.model.T#103]
2008-06-17 20:20:40,970 [main] DEBUG () NullableType: binding '103' to parameter: 1
2008-06-17 20:20:40,970 [main] DEBUG () AbstractEntityPersister: Inserting entity: [net.cellbell.model.T#104]
2008-06-17 20:20:40,970 [main] DEBUG () AbstractBatcher: reusing prepared statement
2008-06-17 20:20:40,970 [main] DEBUG () AbstractBatcher:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
Hibernate:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
2008-06-17 20:20:40,971 [main] DEBUG () AbstractEntityPersister: Dehydrating entity: [net.cellbell.model.T#104]
2008-06-17 20:20:40,971 [main] DEBUG () NullableType: binding '104' to parameter: 1
2008-06-17 20:20:40,971 [main] DEBUG () AbstractEntityPersister: Inserting entity: [net.cellbell.model.T#105]
2008-06-17 20:20:40,972 [main] DEBUG () AbstractBatcher: reusing prepared statement
2008-06-17 20:20:40,972 [main] DEBUG () AbstractBatcher:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
Hibernate:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
2008-06-17 20:20:40,972 [main] DEBUG () AbstractEntityPersister: Dehydrating entity: [net.cellbell.model.T#105]
2008-06-17 20:20:40,973 [main] DEBUG () NullableType: binding '105' to parameter: 1
2008-06-17 20:20:40,973 [main] DEBUG () AbstractEntityPersister: Inserting entity: [net.cellbell.model.T#106]
2008-06-17 20:20:40,973 [main] DEBUG () AbstractBatcher: reusing prepared statement
2008-06-17 20:20:40,975 [main] DEBUG () AbstractBatcher:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
Hibernate:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
2008-06-17 20:20:40,976 [main] DEBUG () AbstractEntityPersister: Dehydrating entity: [net.cellbell.model.T#106]
2008-06-17 20:20:40,977 [main] DEBUG () NullableType: binding '106' to parameter: 1
2008-06-17 20:20:40,977 [main] DEBUG () AbstractEntityPersister: Inserting entity: [net.cellbell.model.T#107]
2008-06-17 20:20:40,977 [main] DEBUG () AbstractBatcher: reusing prepared statement
2008-06-17 20:20:40,978 [main] DEBUG () AbstractBatcher:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
Hibernate:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
2008-06-17 20:20:40,979 [main] DEBUG () AbstractEntityPersister: Dehydrating entity: [net.cellbell.model.T#107]
2008-06-17 20:20:40,979 [main] DEBUG () NullableType: binding '107' to parameter: 1
2008-06-17 20:20:40,979 [main] DEBUG () AbstractEntityPersister: Inserting entity: [net.cellbell.model.T#108]
2008-06-17 20:20:40,980 [main] DEBUG () AbstractBatcher: reusing prepared statement
2008-06-17 20:20:40,980 [main] DEBUG () AbstractBatcher:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
Hibernate:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
2008-06-17 20:20:40,980 [main] DEBUG () AbstractEntityPersister: Dehydrating entity: [net.cellbell.model.T#108]
2008-06-17 20:20:40,981 [main] DEBUG () NullableType: binding '108' to parameter: 1
2008-06-17 20:20:40,981 [main] DEBUG () AbstractEntityPersister: Inserting entity: [net.cellbell.model.T#109]
2008-06-17 20:20:40,982 [main] DEBUG () AbstractBatcher: reusing prepared statement
2008-06-17 20:20:40,982 [main] DEBUG () AbstractBatcher:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
Hibernate:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
2008-06-17 20:20:40,982 [main] DEBUG () AbstractEntityPersister: Dehydrating entity: [net.cellbell.model.T#109]
2008-06-17 20:20:40,983 [main] DEBUG () NullableType: binding '109' to parameter: 1
2008-06-17 20:20:40,983 [main] DEBUG () AbstractEntityPersister: Inserting entity: [net.cellbell.model.T#110]
2008-06-17 20:20:40,983 [main] DEBUG () AbstractBatcher: reusing prepared statement
2008-06-17 20:20:40,983 [main] DEBUG () AbstractBatcher:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
Hibernate:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
2008-06-17 20:20:40,984 [main] DEBUG () AbstractEntityPersister: Dehydrating entity: [net.cellbell.model.T#110]
2008-06-17 20:20:40,984 [main] DEBUG () NullableType: binding '110' to parameter: 1
2008-06-17 20:20:40,984 [main] DEBUG () AbstractEntityPersister: Inserting entity: [net.cellbell.model.T#111]
2008-06-17 20:20:40,984 [main] DEBUG () AbstractBatcher: reusing prepared statement
2008-06-17 20:20:40,985 [main] DEBUG () AbstractBatcher:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
Hibernate:
/* insert net.cellbell.model.T
*/ insert
into
T
(id)
values
(?)
2008-06-17 20:20:40,985 [main] DEBUG () AbstractEntityPersister: Dehydrating entity: [net.cellbell.model.T#111]
2008-06-17 20:20:40,986 [main] DEBUG () NullableType: binding '111' to parameter: 1
2008-06-17 20:20:40,986 [main] DEBUG () BatchingBatcher: Executing batch size: 11
2008-06-17 20:20:40,995 [main] DEBUG () AbstractBatcher: about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2008-06-17 20:20:40,995 [main] DEBUG () AbstractBatcher: closing statement
2008-06-17 20:20:40,995 [main] DEBUG () GooGooStatementCache: checkinStatement(): com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 2; checked out: 0; num connections: 1; num keys: 2
2008-06-17 20:20:40,996 [main] DEBUG () ConnectionManager: registering flush end
2008-06-17 20:20:40,996 [main] DEBUG () AbstractFlushingEventListener: post flush
2008-06-17 20:20:40,996 [main] DEBUG () JDBCContext: before transaction completion
2008-06-17 20:20:40,996 [main] DEBUG () SessionImpl: before transaction completion
2008-06-17 20:20:41,044 [main] DEBUG () JDBCTransaction: re-enabling autocommit
2008-06-17 20:20:41,045 [main] DEBUG () JDBCTransaction: committed JDBC Connection
2008-06-17 20:20:41,045 [main] DEBUG () JDBCContext: after transaction completion
2008-06-17 20:20:41,045 [main] DEBUG () ConnectionManager: aggressively releasing JDBC connection
2008-06-17 20:20:41,045 [main] DEBUG () ConnectionManager: releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2008-06-17 20:20:41,050 [main] DEBUG () GooGooStatementCache: checkinAll(): com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 2; checked out: 0; num connections: 1; num keys: 2
2008-06-17 20:20:41,051 [main] DEBUG () BasicResourcePool: trace com.mchange.v2.resourcepool.BasicResourcePool@104a4b6 [managed: 1, unused: 0, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@b206e9)
2008-06-17 20:20:41,051 [main] DEBUG () SessionImpl: after transaction completion
2008-06-17 20:20:41,051 [main] DEBUG () PersistenceUtil: Closing EntityManager: org.hibernate.ejb.EntityManagerImpl@13c8540...
2008-06-17 20:20:41,052 [main] DEBUG () SessionImpl: closing session
2008-06-17 20:20:41,052 [main] DEBUG () ConnectionManager: connection already null in cleanup : no action
2008-06-17 20:20:41,051 [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] DEBUG () GooGooStatementCache: checkinAll(): com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 2; checked out: 0; num connections: 1; num keys: 2
2008-06-17 20:20:41,055 [main] DEBUG () PersistenceUtil: EntityManager: org.hibernate.ejb.EntityManagerImpl@13c8540 closed.
2008-06-17 20:20:41,055 [main] INFO () PersistenceUtil: Closing main EntityManagerFactory...
2008-06-17 20:20:41,056 [main] INFO () SessionFactoryImpl: closing
2008-06-17 20:20:41,058 [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] DEBUG () ThreadPoolAsynchronousRunner$PoolThread: Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,main] interrupted. Shutting down.
2008-06-17 20:20:41,058 [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] DEBUG () ThreadPoolAsynchronousRunner$PoolThread: Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main] interrupted. Shutting down.
2008-06-17 20:20:41,058 [main] DEBUG () ActiveManagementCoordinator: MBean: com.mchange.v2.c3p0:type=PooledDataSource[1hge11v7u163uw8e90ilzp|405f6] unregistered.
2008-06-17 20:20:41,059 [main] DEBUG () ActiveManagementCoordinator: C3P0Registry mbean unregistered.
2008-06-17 20:20:41,060 [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] DEBUG () ThreadPoolAsynchronousRunner$PoolThread: Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,main] interrupted. Shutting down.
2008-06-17 20:20:41,062 [main] DEBUG () AbstractPoolBackedDataSource: com.mchange.v2.c3p0.PoolBackedDataSource@405f6 has been closed.
--
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, 6 months
[Hibernate-JIRA] Created: (ANN-850) Projection of composite key causes invalid SQL
by Dmitry Katsubo (JIRA)
Projection of composite key causes invalid SQL
----------------------------------------------
Key: ANN-850
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-850
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.1.GA
Environment: Hibernate Annotations 3.4.0.GA
Hibernate Commons Annotations 3.1.0.GA
Hibernate 3.3.1.GA
Reporter: Dmitry Katsubo
Priority: Minor
When using {{Projections.id()}} for the entity, which has a composite ID, the generated SQL is not valid. The expression {{select this_.conceptid as y0_this_.termid as y1_}} should be {{select this_.conceptid as y0_, this_.termid as y1_}} (comma is missed)
07 14:40:37 DEBUG [ConnectionManager] opening JDBC connection
07 14:40:37 DEBUG [SQL]
select
this_.conceptid as y0_this_.termid as y1_,
this_.text as y1_
from
term this_ limit ?
07 14:40:37 DEBUG [AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
07 14:40:37 DEBUG [JDBCExceptionReporter] could not execute query [select this_.conceptid as y0_this_.termid as y1_, this_.text as y1_ from term this_]
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.termid as y1_, this_.text as y1_ from term this_ limit 1000' at line 1
Code:
{quote}
final Session session = sessionFactory.openSession();
try {
return session.createCriteria(TermImpl.class).setProjection(
Projections.projectionList().add(Projections.id()).add(Projections.property("text")))
.setMaxResults(1000).list();
} finally {
session.close();
}
{quote}
Mapped entity:
{quote}
@Entity
@Table(name = "term")
public class TermImpl implements Term, Serializable {
@Embeddable
public static class TermId implements Serializable {
private int id;
private Concept concept;
@Column(name = "termid")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@ManyToOne(targetEntity = ConceptImpl.class)
@JoinColumn(name = "conceptid")
@Fetch(FetchMode.SELECT)
public Concept getConcept() {
return concept;
}
public void setConcept(Concept concept) {
this.concept = concept;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof TermId) {
TermId termId = (TermId) obj;
return id == termId.id && concept.equals(termId.concept);
}
return false;
}
@Override
public int hashCode() {
return id + concept.hashCode();
}
@Override
public String toString() {
final ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
builder.append("concept", concept);
builder.append("id", id);
return builder.toString();
}
}
private TermId id;
private String text;
@Id
public TermId getId() {
return id;
}
public void setId(TermId id) {
this.id = id;
}
@Transient
@Override
public Concept getConcept() {
return id.getConcept();
}
@Column(name = "text")
@Override
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof TermImpl) {
final TermImpl term = (TermImpl) obj;
return id.equals(term.id);
}
return false;
}
@Override
public int hashCode() {
return id.hashCode();
}
@Override
public String toString() {
final ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
builder.append("id", id);
builder.append("text", text);
return builder.toString();
}
}
{quote}
Table structure:
{quote}
CREATE TABLE `term` (
`conceptid` int(11) NOT NULL,
`termid` int(10) unsigned NOT NULL,
`text` varchar(255) default NULL,
PRIMARY KEY (`conceptid`,`termid`)
);
{quote}
--
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, 6 months