[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
16 years
[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
16 years
[Hibernate-JIRA] Commented: (HHH-1015) Incorrect SQL generated when one-to-many foreign key is in a discriminated subclass table
by Gail Badner (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1015?page=c... ]
Gail Badner commented on HHH-1015:
----------------------------------
There is a patch for a unit attached to HHH-3748.
> Incorrect SQL generated when one-to-many foreign key is in a discriminated subclass table
> -----------------------------------------------------------------------------------------
>
> Key: HHH-1015
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1015
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1 beta 2
> Environment: Hibernate versions 3.1 beta 3 and 3.0.5
> Reporter: Steven Grimm
> Priority: Minor
> Attachments: 3.3.2.GA-HHH-1015-v1.patch, hhh-1015-version2.patch, hhh-1015.patch
>
>
> I have the following mappings describing a hierarchy of events and a class that the events refer to:
> <hibernate-mapping package="com.xyz">
> <class name="Event" table="event" discriminator-value="-1">
> <id name="Id" type="long" column="event_id"/>
> <discriminator column="event_type_id" type="integer" />
> <subclass name="EventPayer" discriminator-value="-3">
> <join table="event_payer">
> <key column="event_id" />
> <many-to-one name="payer" column="payer_id" class="Payer" />
> </join>
> <subclass name="EventPayerCreated" discriminator-value="1" />
> </subclass>
> </class>
> <class name="Payer" table="payer">
> <id name="payerId" column="payer_id" type="java.lang.Long"/>
> <set name="eventPayers" inverse="true" cascade="save-update">
> <key column="payer_id"/>
> <one-to-many class="EventPayer"/>
> </set>
> </class>
> </hibernate-mapping>
> When I fetch the Payer.eventPayers collection, Hibernate generates this SQL:
> select eventpayer0_.payer_id as payer7_1_,
> eventpayer0_.event_id as event1_1_,
> eventpayer0_.event_id as event1_5_0_,
> eventpayer0_1_.payer_id as payer2_6_0_,
> eventpayer0_.event_type_id as event2_5_0_
> from event eventpayer0_
> inner join event_payer eventpayer0_1_
> on eventpayer0_.event_id=eventpayer0_1_.event_id
> where eventpayer0_.payer_id=?
> The problem is that there is no event.payer_id column; payer_id is in the child table, not the parent. It appears that specifying a discriminated subclass in <one-to-many> is the same as specifying the superclass, or that Hibernate is ignoring the subclass's <join> element. As far as I can tell, this leaves no way to resolve bidirectional associations where one end of the association is in a discriminated subclass, which seems like a perfectly reasonable thing to want to do.
> I also tried changing <key column="payer_id"/> to <key property-ref="payer"/> in the Payer class's <set> element, but got similar behavior in the form of a "property not found" error: Hibernate is either looking in the superclass's properties rather than the subclass's or is ignoring the list of properties in the <join> element.
--
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
16 years
[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
16 years
[Hibernate-JIRA] Created: (HHH-5176) property-ref doesn't work when property is inside join tags of destination mapping
by Stephen Visser (JIRA)
property-ref doesn't work when property is inside join tags of destination mapping
----------------------------------------------------------------------------------
Key: HHH-5176
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5176
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.0-Final
Environment: mapping
Reporter: Stephen Visser
My legacy system requires that I have a join in the mappings to fully specify.
Here is the mapping of the entity.
{quote}
<hibernate-mapping>
<class name="Student" table="PERSONS" lazy="false">
<id name="personID" column="PERSON_ID"/>
<property name="lastName" column="LEGAL_SURNAME" />
<property name="firstName" column="LEGAL_FIRST_NAME" />
<property name="birthDate" column="DATE_OF_BIRTH" />
<join table="STUDENTS">
<key column="PERSON_ID"/>
<property name="studentID" column="STUDENT_ID" unique="true" />
</join>
</class>
</hibernate-mapping>
{quote}
However, when I reference the entity in another mapping:
{code}
<hibernate-mapping>
<class name="Enrolment" table="COURSE_ENROLLMENTS" lazy="false">
<id name="enrolmentID" column="course_enrollment_id" />
<many-to-one name="student" column="student_id" class="Student" lazy="false" property-ref="studentID"/>
</class>
</hibernate-mapping>
{code}
The studentID property in the Student mapping is assumed to be in the PERSONS table (when in fact it is in the STUDENTS table since it's inside the join tags). This results in the alias of the PERSONS table being prepended to the STUDENT_ID column.
When using the property-ref attribute, it should be determined if the referenced property is inside any join tags. If it is, the correct table alias should be inferred.
--
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
16 years
[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
16 years
[Hibernate-JIRA] Created: (HV-316) Extract constraint checking from ConstraintAnnotationVisitor into separate check classes
by Gunnar Morling (JIRA)
Extract constraint checking from ConstraintAnnotationVisitor into separate check classes
----------------------------------------------------------------------------------------
Key: HV-316
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-316
Project: Hibernate Validator
Issue Type: Improvement
Components: annotation-processor
Affects Versions: 4.1.0.Beta1
Reporter: Gunnar Morling
Assignee: Hardy Ferentschik
Fix For: 4.1.0
Currently the class ConstraintAnnotationVisitor contains all the logic related to constraint checking. For all the different checks (appropriate type, getters not setters annotated etc.) there are check methods, causing the class to become larger and larger as new checks are added.
To improve maintainability all the checks shall be extracted to dedicated check classes. A factory should know which checks have to be executed for given elements and annotations. The visitor should just call this factory, invoke all returned checks and report all errors possibly occurred.
This issue is a pure refactoring, no functionality will be added.
--
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
16 years
[Hibernate-JIRA] Created: (HHH-5169) Columns from other entity with same table name as base class name of table-per-subclass hierarchy appears in SQL queries
by Daniël van 't Ooster (JIRA)
Columns from other entity with same table name as base class name of table-per-subclass hierarchy appears in SQL queries
------------------------------------------------------------------------------------------------------------------------
Key: HHH-5169
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5169
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.1, 3.3.2
Environment: Tested with 3.5.1-Final and 3.3.2.GA
Reporter: Daniël van 't Ooster
Priority: Minor
Sorry for the long title, couln't find anything better which covers the problem.. While mixing some legacy mapping with some new code, Hibernate is mixing some legacy columns and tables with the new ones. Please consider the following mapping.
{code}
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class Bar {
@Column(name = "BarId")
@Id
private long m_id;
// irrelevant stuff omitted
}
@Entity
@Table(name = "Foo")
public class Foo extends Bar {
// irrelevant stuff omitted
}
{code}
So far so good. Now I add some other mappings for the same domain, so they share some names (I have named it NewBar to avoid problems in HQL queries, but this it not relevant for this case).
{code}
@Entity(name = "NewBar")
@Table(name = "Bar")
public class NewBar {
@Id
@Column(name = "NewBarId")
@GeneratedValue
private long m_id;
// irrelevant stuff omitted
}
{code}
The generated schema (for H2) is:
{code}
# Schema for NewBar
create table Bar (
NewBarId bigint generated by default as identity,
primary key (NewBarId)
)
# Schema for old Bar and Foo
create table Foo (
BarId bigint not null,
primary key (BarId)
)
{code}
Nothing wrong with the schema.
Now, when I want to count all old Bar and Foo objects, I execute
{code}
getSession()
.createCriteria(Bar.class)
.setProjection(Projections.rowCount())
.uniqueResult();
{code}
Generated SQL:
{code}
select
count(*) as y0_
from
( select
BarId,
NewBarId,
0 as clazz_
from
Bar
union
all select
BarId,
NewBarId,
1 as clazz_
from
Foo
) this_
{code}
So the columns of the Bar entity and the NewBar (which uses the Bar table) are mixed. In some way, Hibernate is expecting to have a table for the base class of a table-per-subclass hierarchy. Because this is not specified, it uses its entity name. That Table instance is shared over both the Bar and NewBar classes, which result in a from clause which mixes columns from both entities. In the query, nothing is done with the NewBar class, so its columns should not appear in the query.
Workaround is not hard to implement: add a @Table annotation with a unique table name to the base class of the table-per-subclass hierarchy (in this case Bar). This table will not appear in a schema export.
--
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
16 years
[Hibernate-JIRA] Created: (HCANN-23) @Columm does not override column name for join table
by Lynn Keeling (JIRA)
@Columm does not override column name for join table
----------------------------------------------------
Key: HCANN-23
URL: http://opensource.atlassian.com/projects/hibernate/browse/HCANN-23
Project: Hibernate Commons Annotations
Issue Type: Bug
Environment: Hibernate Annotions 3.5.1-Final
MySQL 5.1
Reporter: Lynn Keeling
Priority: Minor
Using the code below, when the table TERRITORY_CHARACTER is created, two columns are created: TERRITORY_ID and characters_CHARACTER_ID. Shouldn't the @Column annotation override the default name and create a column called CHARACTER_ID instead of characters_CHARACTER_ID?
<code>
public class Territory implements Serializable {
private static final long serialVersionUID = -8906914598601073008L;
@Id
@Column(name = "TERRITORY_ID", length = 50)
private String territoryId;
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name="TERRITORY_CHARACTER", joinColumns=@JoinColumn(name="TERRITORY_ID"))
@Column(name="CHARACTER_ID")
private Set<Character> characters;
...
}
public class Character implements Serializable {
private static final long serialVersionUID = 845127746329423630L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "CHARACTER_ID")
private Long characterId;
...
}
</code>
--
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
16 years
[Hibernate-JIRA] Created: (HCANN-22) Problem with @ElementCollection or @CollectionTable in core/annotations 3.5.1 creating bogus unique key
by Lynn Keeling (JIRA)
Problem with @ElementCollection or @CollectionTable in core/annotations 3.5.1 creating bogus unique key
-------------------------------------------------------------------------------------------------------
Key: HCANN-22
URL: http://opensource.atlassian.com/projects/hibernate/browse/HCANN-22
Project: Hibernate Commons Annotations
Issue Type: Bug
Environment: Hibernate Core/Annotions 3.5.1-Final
MySQL 5.1
Reporter: Lynn Keeling
I've encountered a problem that may be a hibernate collection bug. Using the code listed below, I'm creating a collection table that has two columns: TERRITORY_ID and characters_CHARACTER_ID. When hibernate creates the table, it creates the following indexes:
1. An compound unique index on TERRITORY_ID and characters_CHARACTER_ID, which is expected.
2. A non-unique on both TERRITORY_ID and characters_CHARACTER_ID, which is expected.
3. A unique index on characters_CHARACTER_ID, WHICH IS THE PROBLEM I"M REPORTING..
Why is the unique index on characters_CHARACTER_ID being created? If I manually drop the index, my code works fine. Otherwise, I get a unique constraint violation when I try to insert more than one of the same character id into the table. Not the desired behavior.
public class Territory implements Serializable {
private static final long serialVersionUID = -8906914598601073008L;
@Id
@Column(name = "TERRITORY_ID", length = 50)
private String territoryId;
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name="TERRITORY_CHARACTER", joinColumns=@JoinColumn(name="TERRITORY_ID"))
@Column(name="CHARACTER_ID")
private Set<Character> characters;
...
}
public class Character implements Serializable {
private static final long serialVersionUID = 845127746329423630L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "CHARACTER_ID")
private Long characterId;
...
}
--
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
16 years
[Hibernate-JIRA] Created: (HHH-5172) Invalid alias when referencing two different tables in formula tags
by Stephen Visser (JIRA)
Invalid alias when referencing two different tables in formula tags
-------------------------------------------------------------------
Key: HHH-5172
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5172
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.0-Final
Environment: mappings
Reporter: Stephen Visser
I have a complicated Hibernate entity which is defined as the join between two tables. It looks like the following:
{quote}
<hibernate-mapping>
<class name="User" table="PERSONS">
<id name="personID" column="PERSON_ID"/>
<property name="lmsUserName" column="WEB_USERNAME" />
<property name="userName" insert="false" update="false" unique="true">
<formula>
coalesce(lower(WEB_USERNAME), lower(USERNAME))
</formula>
</property>
<join table="APPLICATION_USERS" optional="true">
<key column="PERSON_ID"/>
<property name="sasUserName" column="USERNAME"/>
</join>
</class>
</hibernate-mapping>
{quote}
We can find by criteria as shown below:
{quote}
final Criteria hibernateCriteria = session.createCriteria(User.class).add(Restrictions.eq("userName", "EXAMPLE_USERNAME"));
final User retrievedObject = (User) hibernateCriteria.uniqueResult();
{quote}
This results in the following SQL query being generated:
{quote}
select userimpl0_.PERSON_ID as PERSON1_2_0_, userimpl0_.WEB_USERNAME as WEB5_2_0_, userimpl0_2_.USERNAME as USERNAME4_0_, coalesce(lower(userimpl0_.WEB_USERNAME), lower(userimpl0_.USERNAME)) as formula0_0_,
from PERSONS userimpl0_ left outer join APPLICATION_USERS userimpl0_2_ on userimpl0_.PERSON_ID=userimpl0_2_.PERSON_ID
where coalesce(lower(userimpl0_.WEB_USERNAME), lower(userimpl0_.USERNAME)) = 'EXAMPLE_USERNAME'
{quote}
Due to the nature of our legacy data system, we are trying to find the userName in one of two columns in the DB. A user may have one or both of the user names specified. We want to query by userName in order to avoid making multiple queries. To do this, we make use of the coalesce function as shown above.
The query created by retrieving by userName prepends both WEB_USERNAME and USERNAME in the coalesce function with a single alias. In fact, I need WEB_USERNAME to be prepended with the alias of the PERSONS table (this is done correctly) and USERNAME to be prepended by the alias for the APPLICATION_USERS table (this is where the problem lies).
Ideally, I think it's reasonable to have one of two options:
1) Be able to 'escape' the automatic prepend of table aliases. This would work fine for me as I have no duplicate columns in this example. But I don't think that it is a very universal solution...
2) Be able to reference the alias for a given table using a well-defined syntax (i.e. {PERSONS}.USERNAME )
I've written a little bit here: https://forum.hibernate.org/viewtopic.php?t=1004224
--
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
16 years
[Hibernate-JIRA] Created: (HSEARCH-485) mvn site is currently not working (in ./hibernate-search)
by Emmanuel Bernard (JIRA)
mvn site is currently not working (in ./hibernate-search)
---------------------------------------------------------
Key: HSEARCH-485
URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-485
Project: Hibernate Search
Issue Type: Bug
Components: build
Affects Versions: 3.2.0.Beta1
Reporter: Emmanuel Bernard
Assignee: Hardy Ferentschik
Fix For: 3.2.0
Emmanuel-MBP-15:hibernate-search manu$ mvn site
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Hibernate Search
[INFO] task-segment: [site]
[INFO] ------------------------------------------------------------------------
[INFO] [site:site {execution: default-site}]
[INFO] Generating "Project Team" report.
[INFO] Generating "Issue Tracking" report.
[INFO] Generating "Dependency Management" report.
[INFO] Generating "Continuous Integration" report.
[INFO] Generating "Project Plugins" report.
[INFO] Generating "Dependencies" report.
[WARNING] The repository url 'http://people.apache.org/repo/m2-snapshot-repository' is invalid - Repository 'apache.snapshots' will be blacklisted.
[WARNING] The repository url 'http://people.apache.org/repo/m2-incubating-repository/' is invalid - Repository 'apache-incubator' will be blacklisted.
[INFO] Generating "Plugin Management" report.
[INFO] Generating "Mailing Lists" report.
[INFO] Generating "Source Repository" report.
[INFO] Generating "Project Summary" report.
[INFO] Generating "About" report.
[INFO] Generating "Project License" report.
[INFO] [jdocbook:translate {execution: make-doc}]
can't find
The next section demonstrates how to programmatically define analyzers.
in
he next section demonstrates how to programmatically define analyzers.</para>
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Unexpected problem
Embedded error: uanble to execute po2xml : Process exited with an error: 1(Exit value: 1)
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4 minutes 7 seconds
[INFO] Finished at: Fri Apr 02 11:47:35 CEST 2010
[INFO] Final Memory: 59M/151M
[INFO] ------------------------------------------------------------------------
--
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
16 years
[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
16 years
[Hibernate-JIRA] Created: (HHH-5166) Inconsistent session state with merge/evict on cascade="all" association
by Alexandre FRADIN (JIRA)
Inconsistent session state with merge/evict on cascade="all" association
------------------------------------------------------------------------
Key: HHH-5166
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5166
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.1, 3.3.2
Environment: Reproducted on :
Hibernate-core 3.3.2 and 3.5.1-Final
DB2 and HSQL DB
with annotation and classic hbm mapping
Reporter: Alexandre FRADIN
Priority: Critical
Attachments: hibernate-test-merge-evict-cascade-all.zip
My apologies for my English.
I have entities User and Role with a many-to-many association mapped with cascade="all". So merge and evict operations on User should be applied to this association.
When I do the following :
1) create user u existing in DB
2) add a new Role r to this user (this Role don't exists in DB)
3) merge u
4) evict the instance returned by the merge operation
5) use the same session for any operation
6) commit the session
I get this exception : "org.hibernate.AssertionFailure: possible nonthreadsafe access to session".
There is no thread issue. I think this is a standard way to use merge and evict operations.
I think that merge and evict operations used on modified entities leave the session in an inconsistent state.
See unit test wich reproduct this bug.
Does a workaround exist for this bug?
Regards.
--
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
16 years
[Hibernate-JIRA] Created: (HHH-5165) FetchMode=Eager not respected, N+1 SELECT Problem
by David Bernhard (JIRA)
FetchMode=Eager not respected, N+1 SELECT Problem
-------------------------------------------------
Key: HHH-5165
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5165
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.2
Environment: (as Maven artifacts)
org.hibernate:hibernate-core:jar:3.3.2.GA
org.hibernate:hibernate-annotations:jar:3.4.0.GA
org.hibernate:ejb3-persistence:jar:1.0.2.GA
org.hibernate:hibernate-validator:jar:3.1.0.GA
org.hibernate:hibernate-commons-annotations:jar:3.1.0.GA
org.hibernate:hibernate-search:jar:3.1.0.GA
org.hibernate:hibernate-entitymanager:jar:3.4.0.GA
Reporter: David Bernhard
Priority: Minor
Two classes A, B with 1:n relationship. Fetching all instances of B with an empty DetachedCriteria instance does not repsect FetchMode.JOIN but issues a SELECT for each A (N+1 SELECT problem).
This causes the bug:
findByCriteria(DetachedCriteria.forClass(B.class));
This works - but I need that second setFetchMode:
findByCriteria(DetachedCriteria.forClass(B.class)
.setFetchMode("a", FetchMode.JOIN)
.setFetchMode("a.bs", FetchMode.JOIN)
);
HQL works too. Here are two classes that cause the bug:
@Entity @Table(name = "A")
@SequenceGenerator(name = "keyid_generator", sequenceName = "A_sequence")
public class A extends AbstractIntKeyIntOptimisticLockingDto {
private String name;
private Set<B> bs;
@OneToMany(mappedBy = "a", fetch = FetchType.EAGER)
@Fetch(FetchMode.JOIN)
public Set<B> getBs() {
return bs;
}
public void setBs(Set<B> bs) {
this.bs = bs;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@Entity @Table(name = "B")
@SequenceGenerator(name = "keyid_generator", sequenceName = "B_sequence")
public class B extends AbstractIntKeyIntOptimisticLockingDto {
private String name;
private A a;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "a", nullable = false,
unique = false, updatable = false)
@Fetch(FetchMode.JOIN)
public A getA() {
return a;
}
public void setA(A a) {
this.a = a;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
--
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
16 years
[Hibernate-JIRA] Created: (HHH-5161) JPA 2.0 criteria queries do not use parameters for numeric fields
by Tarek Nabil (JIRA)
JPA 2.0 criteria queries do not use parameters for numeric fields
-----------------------------------------------------------------
Key: HHH-5161
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5161
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.5.0-Final
Environment: Hibernate 3.5.0 with Oracle DB.
Reporter: Tarek Nabil
Attachments: param-bug.zip
Using the new JPA 2.0 criteria API to create a query whose where clause consists of one or more predicates, where one of those predicates compares a numeric (int or long) field in an entity to a certain value, the generated query uses the compared value literally in the query where it should have used a parameter.
The attached test case illustrates the problem. It's a minimal Maven2 project which contains one domain class and one DAO.
The domain class maps to the REGION entity from the Oracle HR schema which ships with any Oracle XE installation. I still included the script needed to create the table incase the schema is not available on the test environment.
The DAO has one method which creates a query that selects a region by id and then extracts the set of parameters from the generated TypedQuery. The method then returns the size of the set to the test method which fails if the size is not greater than zero.
The DAO method also executes the query and since Hibernate is configured to show the generated SQL, the following query is shown in standard output:
select
region0_.REGION_ID as REGION1_0_,
region0_.REGION_NAME as REGION2_0_
from
REGIONS region0_
where
region0_.REGION_ID=1
Where the correct query should have been:
select
region0_.REGION_ID as REGION1_0_,
region0_.REGION_NAME as REGION2_0_
from
REGIONS region0_
where
region0_.REGION_ID=?
IMO, this is a major issue as it can have a severe impact on on Oracle DB performance as it will have to hard parse the query every time it's used with a different value.
I've provided instructions on the minimal changes required to setup the Maven project in order to run the test case in "readme.txt".
--
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
16 years
[Hibernate-JIRA] Updated: (HHH-1123) Cannot put more than 1000 elements in a InExpression
by Strong Liu (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1123?page=c... ]
Strong Liu updated HHH-1123:
----------------------------
Issue Type: Improvement (was: Bug)
change this to improvment
> Cannot put more than 1000 elements in a InExpression
> ----------------------------------------------------
>
> Key: HHH-1123
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1123
> Project: Hibernate Core
> Issue Type: Improvement
> Components: core
> Affects Versions: 3.1 rc2, 3.2.0.alpha1
> Environment: Oracle 9i
> Reporter: Alexis Seigneurin
> Assignee: Strong Liu
> Attachments: Animal.hbm.xml, hibernate-inexpression-oracle-3.2.patch, LongInElementsTest.java, patch.txt
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> The number of elements that we can put in a "in" expression is limited to a certain amount (1000 for Oracle, for instance). When creating a criteria query, the org.hibernate.criterion.InExpression class should split the expression into several smaller ones.
> Attached is a patch which splits the expression by slices of 500 elements. For example, if we have 1001 elements to put in the "in" expression, the result would be :
> (entity.field in (?, ?, ?...) or entity.field in (?, ?, ?...) or entity.field in (?))
> The surrounding parantheses are useful to avoid problems with other conditions (a "and" condition taking over the one of the "or" conditions).
--
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
16 years
[Hibernate-JIRA] Created: (HHH-5167) NullPointerException on double-save of versioned entity
by Robert Hailey (JIRA)
NullPointerException on double-save of versioned entity
-------------------------------------------------------
Key: HHH-5167
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5167
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.2
Environment: PostgreSQL 8.3.3, Hibernate 3.3.2.GA (2009-06-24)
Reporter: Robert Hailey
Priority: Minor
(psuedocode)
VersionedPojo v=new VersionedPojo();
session.save(v);
String secondary=functionNeedingId(v.getId());
v.setSecondary(secondary);
session.saveOrUpdate(v);
--
A common example of a function needing an id might include the saving of a many-to-one relationships. This stack trace has been seen in forum posts and is very likely to be this same issue.
--
java.lang.NullPointerException
at org.hibernate.type.LongType.next(LongType.java:79)
at org.hibernate.engine.Versioning.increment(Versioning.java:131)
at org.hibernate.event.def.DefaultFlushEntityEventListener.getNextVersion(DefaultFlushEntityEventListener.java:387)
at org.hibernate.event.def.DefaultFlushEntityEventListener.scheduleUpdate(DefaultFlushEntityEventListener.java:279)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:151)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:49)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:366)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
--
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
16 years
[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
16 years
[Hibernate-JIRA] Created: (HHH-5112) Accessing an object containing a *ToOne-Association using NO_PROXY option for lazy fetching
by Saša Obradović (JIRA)
Accessing an object containing a *ToOne-Association using NO_PROXY option for lazy fetching
-------------------------------------------------------------------------------------------
Key: HHH-5112
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5112
Project: Hibernate Core
Issue Type: Bug
Components: core, envers
Affects Versions: 3.5.0-Final, 3.3.2
Environment: Oracle, instrumentation using Javassist
Reporter: Saša Obradović
Attachments: enversbug.jpg, field [id] not found.zip, oracle-ddl.sql
Adding an element to a collection:
{{A a = entityManager.find(A.class, 505L);}}
{{B b = new B();}}
{{a.addToB(b);}}
results in following exception:
{quote}
javax.persistence.PersistenceException: org.hibernate.PropertyNotFoundException: field [id] not found on org.hibernate.intercept.LazyPropertyInitializer$1
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1179)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1112)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1118)
at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:738)
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
at $Proxy90.flush(Unknown Source)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
at $Proxy90.flush(Unknown Source)
at at.ing.diba.helper.TestMethodFlusherBeanAspect.executeFlush(TestMethodFlusherBeanAspect.java:27)
at at.ing.diba.service.architektur.BugTest.testEnvers_aroundBody6(BugTest.java:69)
at at.ing.diba.service.architektur.BugTest$AjcClosure7.run(BugTest.java:1)
at at.ing.diba.manager.ServiceMethodTracingAspect.traceServiceMethod(ServiceMethodTracingAspect.java:40)
at at.ing.diba.service.architektur.BugTest.testEnvers(BugTest.java:65)
at org.springframework.test.context.testng.AbstractTestNGSpringContextTests.run(AbstractTestNGSpringContextTests.java:158)
Caused by: org.hibernate.PropertyNotFoundException: field [id] not found on org.hibernate.intercept.LazyPropertyInitializer$1
at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:182)
at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:174)
at org.hibernate.property.DirectPropertyAccessor.getGetter(DirectPropertyAccessor.java:197)
at org.hibernate.envers.entities.mapper.id.SingleIdMapper.mapToMapFromEntity(SingleIdMapper.java:104)
at org.hibernate.envers.entities.mapper.relation.ToOneIdMapper.mapToMapFromEntity(ToOneIdMapper.java:68)
at org.hibernate.envers.entities.mapper.MultiPropertyMapper.map(MultiPropertyMapper.java:86)
at org.hibernate.envers.synchronization.work.ModWorkUnit.<init>(ModWorkUnit.java:48)
at org.hibernate.envers.event.AuditEventListener.onPostUpdate(AuditEventListener.java:165)
at org.hibernate.action.EntityUpdateAction.postUpdate(EntityUpdateAction.java:199)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:178)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:268)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:260)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:180)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:735)
... 47 more
{quote}
The exception is related to the association between A and C, although it hasn't changed in the transaction. No exception is thrown if the lazy fetching of C (in class A) is declared "proxy".
--
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
16 years
[Hibernate-JIRA] Created: (HHH-5143) Lazy Loading Not Working for @OneToOne Associations With LazyToOneOption.PROXY
by j nadler (JIRA)
Lazy Loading Not Working for @OneToOne Associations With LazyToOneOption.PROXY
------------------------------------------------------------------------------
Key: HHH-5143
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5143
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.1
Environment: Hibernate Core 3.5.1-Final, MySQL 5.1
Reporter: j nadler
I'm using 3.5.1. Two persistent entities, parent and child, are in a one to one relationship:
In Parent, the reference to Child:
@OneToOne(optional=false, fetch=FetchType.LAZY, cascade={ CascadeType.MERGE, CascadeType.REMOVE, CascadeType.REFRESH, CascadeType.PERSIST })
@LazyToOne(LazyToOneOption.PROXY)
@JoinColumn(name = "childId")
@ForeignKey(name="FK_Parent_Child")
@IndexedEmbedded()
public Child getChild() {
return child;
}
public void setChild(Child child) {
this.child = child;
}
And in Child, the reference to Parent:
@OneToOne(mappedBy="child", fetch=FetchType.LAZY)
@LazyToOne(LazyToOneOption.PROXY)
@ContainedIn
public Parent getParent() {
return parent;
}
public void setParent(Parent parent) {
this.parent = parent;
}
When I load a Parent entity via HQL, I see three SQL queries:
-one that corresponds to my HQL query
-one that loads Child
-one that loads Parent from the Child's perspective
I'm watching it in JProfiler and it's hurting our app performance significantly because Child contains LOBs that are rarely needed.
I tried making it a unidirectional association (no reference from Child back to Parent) but the expensive SQL call (loading Child) still happens. That gets it down to two SQL queries:
-one that corresponds to my HQL query
-one that loads Child (the expensive one)
We are using the stock javassist proxies and no bytecode enhancement.
--
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
16 years
[Hibernate-JIRA] Created: (HHH-4773) unit tests fail cos db2 doesn't allow primary key column nullable
by Strong Liu (JIRA)
unit tests fail cos db2 doesn't allow primary key column nullable
-----------------------------------------------------------------
Key: HHH-4773
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4773
Project: Hibernate Core
Issue Type: Bug
Components: testsuite
Affects Versions: 3.5.0-Beta-2, 3.5.0.Beta-1, 3.3.2
Environment: db2
Reporter: Strong Liu
org.hibernate.search.test.embedded.EmbeddedTest.testIndexedEmbeddedAndCollections
Column 'CUST_NAME' is part of a primary key constraint and cannot be null.
org.hibernate.test.annotations.target.TargetTest.testTargetOnMapKey
19:47:29,104 DEBUG SchemaExport:377 -
create table Brand_LuggageImpl (
Brand_id bigint not null,
luggagesBySize_id bigint not null,
name varchar(255),
primary key (Brand_id, name)
)
19:47:29,129 ERROR SchemaExport:348 - Unsuccessful: create table Brand_LuggageImpl (Brand_id bigint not null, luggagesBySize_id bigint not null, name varchar(255), primary key (Brand_id, name))
org.hibernate.test.annotations.collectionelement.indexedCollection.IndexedCollectionOfElementsTest.testIndexedCollectionOfElements
create table contact (
n_key_person integer not null,
name varchar(255),
n_key_contact bigint,
primary key (n_key_contact)
)
19:45:24,074 ERROR SchemaExport:348 - Unsuccessful: create table contact (n_key_person integer not null, name varchar(255), n_key_contact bigint, primary key (n_key_contact))
19:45:24,073 ERROR SchemaExport:349 - DB2 SQL error: SQLCODE: -542, SQLSTATE: 42831, SQLERRMC: N_KEY_CONTACT
org.hibernate.test.annotations.any.AnyTest.testManyToAnyWithMap
19:43:44,418 DEBUG SchemaExport:377 -
alter table map_properties
add constraint FKF2788BF69AF4A643
foreign key (map_id)
references property_map
19:43:44,420 ERROR SchemaExport:348 - Unsuccessful: alter table map_properties add constraint FKF2788BF69AF4A643 foreign key (map_id) references property_map
19:43:44,420 ERROR SchemaExport:349 - DB2 SQL error: SQLCODE: -204, SQLSTATE: 42704, SQLERRMC: HIBBR330.MAP_PROPERTIES
org.hibernate.test.annotations.identifiercollection.IdentifierCollectionTest.testIdBag
19:44:05,449 DEBUG SchemaExport:377 -
create table PASSPORT_STAMP (
Passport_passport_id bigint not null,
stamps_id bigint not null,
COLLECTION_ID bigint,
primary key (COLLECTION_ID)
)
19:44:05,494 ERROR SchemaExport:348 - Unsuccessful: create table PASSPORT_STAMP (Passport_passport_id bigint not null, stamps_id bigint not null, COLLECTION_ID bigint, primary key (COLLECTION_ID))
19:44:05,493 ERROR SchemaExport:349 - DB2 SQL error: SQLCODE: -542, SQLSTATE: 42831, SQLERRMC: COLLECTION_ID
19:44:05,494 DEBUG SchemaExport:377 -
create table PASSPORT_VISASTAMP (
Passport_passport_id bigint not null,
visaStamp_id bigint not null,
COLLECTION_ID bigint,
primary key (COLLECTION_ID)
)
19:44:05,526 ERROR SchemaExport:348 - Unsuccessful: create table PASSPORT_VISASTAMP (Passport_passport_id bigint not null, visaStamp_id bigint not null, COLLECTION_ID bigint, primary key (COLLECTION_ID))
19:44:05,525 ERROR SchemaExport:349 - DB2 SQL error: SQLCODE: -542, SQLSTATE: 42831, SQLERRMC: COLLECTION_ID
org.hibernate.test.annotations.indexcoll.IndexedCollectionTest.testRealMap
19:46:31,064 DEBUG SchemaExport:377 -
create table Atmosphere_Gas (
Atmosphere_id integer not null,
gases_id integer not null,
gas_name varchar(255),
primary key (Atmosphere_id, gas_name)
)
19:46:31,093 ERROR SchemaExport:348 - Unsuccessful: create table Atmosphere_Gas (Atmosphere_id integer not null, gases_id integer not null, gas_name varchar(255), primary key (Atmosphere_id, gas_name))
19:46:31,094 ERROR SchemaExport:349 - DB2 SQL error: SQLCODE: -542, SQLSTATE: 42831, SQLERRMC: GAS_NAME
org.hibernate.test.annotations.collectionelement.CollectionElementTest
19:45:09,816 DEBUG SchemaExport:377 -
create table Matrix_values (
Matrix_id integer not null,
element float,
mapkey integer,
primary key (Matrix_id, mapkey)
)
19:45:09,844 ERROR SchemaExport:348 - Unsuccessful: create table Matrix_values (Matrix_id integer not null, element float, mapkey integer, primary key (Matrix_id, mapkey))
19:45:09,845 ERROR SchemaExport:349 - DB2 SQL error: SQLCODE: -542, SQLSTATE: 42831, SQLERRMC: MAPKEY
19:45:09,844 DEBUG SchemaExport:377 -
create table ScorePerNickName (
BoyId integer not null,
fld_score integer,
mapkey varchar(255),
primary key (BoyId, mapkey)
)
19:45:09,872 ERROR SchemaExport:348 - Unsuccessful: create table ScorePerNickName (BoyId integer not null, fld_score integer, mapkey varchar(255), primary key (BoyId, mapkey))
19:45:09,871 ERROR SchemaExport:349 - DB2 SQL error: SQLCODE: -542, SQLSTATE: 42831, SQLERRMC: MAPKEY
19:45:09,871 DEBUG SchemaExport:377 -
create table TestCourse (
testCourseId bigint generated by default as identity,
primary key (testCourseId)
)
19:45:09,920 DEBUG SchemaExport:377 -
create table TestCourse_variations (
TestCourse_testCourseId bigint not null,
element varchar(255),
language_code varchar(255),
primary key (TestCourse_testCourseId, language_code)
)
19:45:09,944 ERROR SchemaExport:348 - Unsuccessful: create table TestCourse_variations (TestCourse_testCourseId bigint not null, element varchar(255), language_code varchar(255), primary key (TestCourse_testCourseId, language_code))
19:45:09,946 ERROR SchemaExport:349 - DB2 SQL error: SQLCODE: -542, SQLSTATE: 42831, SQLERRMC: LANGUAGE_CODE
--
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
16 years
[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
16 years
[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
16 years
[Hibernate-JIRA] Commented: (HHH-1341) Query.setMaxResults does not work with Mysql Connector version 3.1.6, but works with 3.0.14
by Strong Liu (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1341?page=c... ]
Strong Liu commented on HHH-1341:
---------------------------------
I cant reproduce this issue with both hibernate 3.5.x and 3.3.2, with mysql connector 5.1.8.
I used the test org.hibernate.test.pagination.PaginationTest, you can found it in hibernate testsuite, please let me know if you can reproduce it and if possible, attache a runnable test case(pojo + hbm), thanks
> Query.setMaxResults does not work with Mysql Connector version 3.1.6, but works with 3.0.14
> -------------------------------------------------------------------------------------------
>
> Key: HHH-1341
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1341
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1
> Environment: Hibernate 3.1, Mysql Server 4.1.3, Mysql Connector 3.1.6 bzw. 3.0.14, JRE 1.5.0_06, winxp
> Reporter: Stefan Reger
> Assignee: Strong Liu
> Priority: Minor
>
> With Mysql Connector version 3.1.6: Setting query.setMaxResults(1000) results in console output:
> "Hibernate: select [...] limit ?
> 13:38:47,296 WARN JDBCExceptionReporter:71 - SQL Error: 1064, SQLState: 42000
> 13:38:47,296 ERROR JDBCExceptionReporter:72 - 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 '?' at line 1"
> The query without setting the result limit succeeds.
> Mysql Connector 3.0.14 works perfectly. Please verify.
--
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
16 years
[Hibernate-JIRA] Assigned: (HHH-1341) Query.setMaxResults does not work with Mysql Connector version 3.1.6, but works with 3.0.14
by Strong Liu (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1341?page=c... ]
Strong Liu reassigned HHH-1341:
-------------------------------
Assignee: Strong Liu
> Query.setMaxResults does not work with Mysql Connector version 3.1.6, but works with 3.0.14
> -------------------------------------------------------------------------------------------
>
> Key: HHH-1341
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1341
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1
> Environment: Hibernate 3.1, Mysql Server 4.1.3, Mysql Connector 3.1.6 bzw. 3.0.14, JRE 1.5.0_06, winxp
> Reporter: Stefan Reger
> Assignee: Strong Liu
> Priority: Minor
>
> With Mysql Connector version 3.1.6: Setting query.setMaxResults(1000) results in console output:
> "Hibernate: select [...] limit ?
> 13:38:47,296 WARN JDBCExceptionReporter:71 - SQL Error: 1064, SQLState: 42000
> 13:38:47,296 ERROR JDBCExceptionReporter:72 - 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 '?' at line 1"
> The query without setting the result limit succeeds.
> Mysql Connector 3.0.14 works perfectly. Please verify.
--
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
16 years
[Hibernate-JIRA] Created: (HHH-3798) failure to lazy load a manyToOne and oneToMany mapped entity
by Ronald Kurz (JIRA)
failure to lazy load a manyToOne and oneToMany mapped entity
------------------------------------------------------------
Key: HHH-3798
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3798
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1, 3.5
Environment: hibernate annotations test case, maven profile hsqldb, svn rev 16079
hibernate-core 3.3.1.GA, JBoss 4.2.3, SQLServer 2000
Reporter: Ronald Kurz
Attachments: test-case.tar.gz
Following situtation: an entity Data has Revision entities (oneToMany). Each Revision entity belongs to a Data entity. The Data entity has one manyToOne mapping to the current Revision. The mappings from Data to Revision are all lazy.
When loading a Data entity, which has two Revisions, the Revision entity which is also mapped as manyToOne (the current Revision for that Data entity), does not get loaded. It will be an uninitialized proxy, which is also resistent to Hibernate.initialize(<Data>.revision). The same proxy is also in the oneToMany mapped list.
@Entity
public class Data {
@Id @GeneratedValue
public int id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "revisionId")
public Revision revision;
@OneToMany(mappedBy = "data")
public List<Revision> revisions = new ArrayList<Revision>();
}
@Entity
public class Revision {
@Id @GeneratedValue
public int id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "dataId", nullable = false, updatable = false)
public Data data;
public Integer number;
}
The test case is written for the hibernate-annotations project (simply because I never wrote a mapping using xml)
--
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
16 years
[Hibernate-JIRA] Created: (HHH-5137) NULLIF misinterpreted when a comma is set as a decimal point (DB2 z/OS)
by Leonardo (JIRA)
NULLIF misinterpreted when a comma is set as a decimal point (DB2 z/OS)
-----------------------------------------------------------------------
Key: HHH-5137
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5137
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.2
Environment: Hibernate 3.3.2.GA, DB2 9 for z/OS
Reporter: Leonardo
Priority: Minor
If we set in DB2 a comma (instead a period) as a separator for decimal point I get an error when Hibernate executes this query:
DEBUG SQL:111 - select foo0_.id as id0_0_, foo0_.myBar_id as myBar1_3_0_, foo0_.clazz_ as clazz_0_ from ( select nullif(0,0) as myBar_id, id, 0 as clazz_ from Foo union all select nullif(0,0) as myBar_id, id, 1 as clazz_ from SubFoo2 union all select myBar_id, id, 2 as clazz_ from SubFoo1 ) foo0_ where foo0_.id=?
com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -170,
SQLSTATE: 42605, SQLERRMC: NULLIF
In fact, DB2 interprets the argument of nullif(0,0) as a decimal number and not as two arguments (zero, zero). DB2 documentation [1] says that if the comma is set as a decimal point a comma intended as a separator must be followed by a space. so in that case, nullif(0, 0) (note space after ',').
We are using DB2390Dialect and getSelectClauseNullString(int sqlType) method doesn't generate a correct nullif instruction in this case.
we could circumvent this issue by extending DB2390Dialect class and placing spaces after comma like this: return "nullif(" + literal + ", " + literal + ')'. But isn't a proper solution for us because we must release an extra jar with custom dialect to our customers.
[1] http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/c...
--
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
16 years
[Hibernate-JIRA] Closed: (HHH-442) hibernate does not handle correctly covariant return types of java 1.5.
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-442?page=co... ]
Steve Ebersole closed HHH-442.
------------------------------
Resolution: Duplicate
> hibernate does not handle correctly covariant return types of java 1.5.
> -----------------------------------------------------------------------
>
> Key: HHH-442
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-442
> Project: Hibernate Core
> Issue Type: Bug
> Affects Versions: 3.0.2
> Environment: INFO: Hibernate 3.0.2
> Windows XP Pro
> java version "1.5.0_03"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
> Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)
> Reporter: Stefan Bühlmann
> Priority: Minor
> Attachments: covariant_problem.zip
>
>
> Hi Gavin,
> It seems as if hibernate does not handle correctly covariant return types of java 1.5.
> In the example included LocalWorkspace implements LocalWorkspaceI.
> The attribute visibleCommittedTrx and it's setters and getters use the type Transaction;
> But the interface LocalWorkspaceI uses TransactionI as a return type for getVisibleCommittedTrx().
> To put it the other way around, LocalWorkspace.getVisibleCommittedTrx() returns a class and not an interface, but this still implements the interface, since it is a covariant return type.
> It compiles nicely with java 1.5, but when run it get the following:
> org.hibernate.MappingException: An association from the table LOCALWORKSPACE refers to an unmapped class: x2.elements.interfaces.TransactionI
> This clearly shows, that hibernate tries to use TransactionI. But I never made a mapping for an interface!
> To use the stripped down example, just edit go.bat and set JAVA_HOME to your liking. Then run go.bat.
> But how can I upload a zip?
> Bye Stefan
--
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
16 years
[Hibernate-JIRA] Created: (HHH-5141) hql group by on multiple classes generates 1 query by class and can return a wrong number of results
by Eric Citaire (JIRA)
hql group by on multiple classes generates 1 query by class and can return a wrong number of results
----------------------------------------------------------------------------------------------------
Key: HHH-5141
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5141
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.3.0.SP1
Environment: Hibernate Annotations 3.4.0.GA, HSQLDB 1.8.0.10
Reporter: Eric Citaire
Priority: Critical
The classes DomesticDog and DomesticCat extend / implement Pet.
Here is the data of the 2 tables :
{{DomesticDog}}
{{+----+----------------------+}}
{{| 1 | Max |}}
{{| 2 | Buddy |}}
{{| 3 | Jake |}}
{{| 4 | Buddy |}}
{{+----+----------------------+}}
{{DomesticCat}}
{{+----+----------------------+}}
{{| 1 | Tiger |}}
{{| 2 | Smokey |}}
{{| 3 | Tiger |}}
{{| 4 | Max |}}
{{+----+----------------------+}}
Given the HQL query :
{{select pet.name from Pet pet group by pet.name having count(pet) > 1}}
Two SQL queries are generated and executed separately :
{{select domesticdog0_.name as col_0_0_ from DomesticDog domesticdog0_ group by domesticdog0_.name having count(domesticdog0_.id)>1}}
{{select domesticcat0_.name as col_0_0_ from DomesticCat domesticcat0_ group by domesticcat0_.name having count(domesticcat0_.id)>1}}
It returns only : "Buddy" and "Smokey". But it does not return "Max" wich is the name of a cat and a dog.
--
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
16 years
[Hibernate-JIRA] Created: (HHH-5099) Bug in CriteriaBuilder.in(Collection): IllegalArgumentException
by Max Hartmann (JIRA)
Bug in CriteriaBuilder.in(Collection): IllegalArgumentException
---------------------------------------------------------------
Key: HHH-5099
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5099
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.0-Final
Environment: hibernate 3.5, oracle 10g
Reporter: Max Hartmann
Method CriteriaBuilder.in(Collection<?> values) throws an IllegalArgumentException. It's a wonder, but when I call CriteriaBuilder.in(Object... values) no Exception is thrown.
Exception:
Exception in thread "main" java.lang.IllegalArgumentException: Parameter value [1] was not matching type [java.util.Arrays$ArrayList]
at org.hibernate.ejb.AbstractQueryImpl.registerParameterBinding(AbstractQueryImpl.java:340)
at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:354)
at org.hibernate.ejb.criteria.expression.LiteralExpression$1.bind(LiteralExpression.java:84)
at org.hibernate.ejb.criteria.CriteriaQueryCompiler.compile(CriteriaQueryCompiler.java:174)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:432)
at test.server.TestApp.main(TestApp.java:29)
Code:
EntityManagerFactory factory = Persistence
.createEntityManagerFactory("userDatabase");
EntityManager em = factory.createEntityManager();
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> createQuery = cb.createQuery(String.class);
Root<TestBean> from = createQuery.from(TestBean.class);
createQuery.select(cb.function("TO_CHAR", String.class, from
.get(TestBean_.date1))).where(from
.get(TestBean_.id).in(Arrays.asList(new String[] {"1", "2"})));
List<String> resultList = em.createQuery(createQuery).getResultList();
--
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
16 years
[Hibernate-JIRA] Created: (HHH-5157) Discriminating on a value in a joined table
by Nicholas White (JIRA)
Discriminating on a value in a joined table
-------------------------------------------
Key: HHH-5157
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5157
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.5.1
Reporter: Nicholas White
I'm re-opening http://opensource.atlassian.com/projects/hibernate/browse/HHH-506 as the following case doesn't work, and HHH-506 doesn't provide a solution in enough detail:
Tables (for an Oracle database):
create table values (object integer, paramname varchar2(100), stringvalue varchar2(100), numbervalue integer);
create table types (paramname varchar2(100), isstring char(1));
create table objects (id integer);
Classes (missing getters and setters for readability reasons):
class Object { private Integer id; private Set<Value> parameters;}
abstract class Value {private String paramname;}
class StringValue extends Value { private String value;}
class IntegerValue extends Value { private Integer value;}
I'd like to use the isstring column in the types table as a discriminator - if it is 'Y' then the StringValue subclass should be generated with a value field populated from the stringvalue column of the values table. If it is 'N' then I'd like an IntegerValue subclass to be created with its value field populated from the numbervalue column of the values table.
Please don't reject this without providing an hbm.xml mappings file that maps this structure (and that works with an Oracle database).
Thanks,
Nick
--
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
16 years