[Hibernate-JIRA] Commented: (HHH-271) subclass lazy fetching returns wrong object
by Fred Arters (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-271?page=co... ]
Fred Arters commented on HHH-271:
---------------------------------
6 years later and I ran into this same situation. I found that the lazy fetch was causing the problem from another ticket, regarding using discriminator fields with InheritanceType=JOINED. The answer to that rejected ticket was that hibernate was elegant enough not to need discriminator fields for joined inheritance. Someone brought up that if hibernate supported discriminator fields in these cases, lazy fetches for inherited classes would return the correct sub-type. Seems like the answer to that ticket and the answer to this one are in conflict. Additionally, I would, and did not, expect that changing the fetch type to lazy would return a different result than eager fetch. In my case an eager fetch is not going to hurt me so I will do that.
> subclass lazy fetching returns wrong object
> -------------------------------------------
>
> Key: HHH-271
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-271
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.0 rc 1
> Reporter: Michael Kopp
>
> I have a table per hierarchy mapping with discriminators. Another class has a many-to-one relation to the root class. When my program accesses the getter for this many-to-one relation, it should get a subclass of the root class. What it gets is a CGLIB proxy of the root class (com.j2fe.workflow.definition.Node$$EnhancerByCGLIB$$63e262e8).
> When I turn of lazy fetching on the root class (Node) everything works as expected.
> I have another class with a one-to-many collection of the root class. If I iterate through this before accessing the many-to-one getter, It also works correctly.
> One important note at last, the discriminator is set to force.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 3 months
[Hibernate-JIRA] Created: (HHH-3440) 3.3.0 GA with MySQL 5.0 throws table validation exception
by Carlo Luib-Finetti (JIRA)
3.3.0 GA with MySQL 5.0 throws table validation exception
---------------------------------------------------------
Key: HHH-3440
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3440
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.3.0.GA
Environment: Hibernate 3.3.0 GA
MySQL 5.0
JBoss 4.2.2
Reporter: Carlo Luib-Finetti
Hibernate immediately throws an exception at application startup, when it does the schema validation.
org.hibernate.HibernateException: Wrong column type in dpjw.assessment for column NOTES. Found: text, expected: longtext
Comparing the sources of 3.2.0 with 3.3.0 I can see that someone set two java statements into comment. The 3.2 version of MySQLDialect.java looks like this:
protected void registerVarcharTypes() {
registerColumnType( Types.VARCHAR, "longtext" );
registerColumnType( Types.VARCHAR, 16777215, "mediumtext" );
registerColumnType( Types.VARCHAR, 65535, "text" );
registerColumnType( Types.VARCHAR, 255, "varchar($l)" );
}
while the new 3.3.0 version is this:
protected void registerVarcharTypes() {
registerColumnType( Types.VARCHAR, "longtext" );
// registerColumnType( Types.VARCHAR, 16777215, "mediumtext" );
// registerColumnType( Types.VARCHAR, 65535, "text" );
registerColumnType( Types.VARCHAR, 255, "varchar($l)" );
}
If I uncomment these (and others in the same Java file!), the validation process is ok.
Is there any reason why these statements (and others!) were commented out???
--
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
13 years, 3 months
[Hibernate-JIRA] Created: (HHH-3530) The code in the 3.3.1.GA subversion tag is not the code that's been released on the maven repository.jboss.org as 3.3.1.GA
by Geoffrey De Smet (JIRA)
The code in the 3.3.1.GA subversion tag is not the code that's been released on the maven repository.jboss.org as 3.3.1.GA
--------------------------------------------------------------------------------------------------------------------------
Key: HHH-3530
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3530
Project: Hibernate Core
Issue Type: Bug
Components: build
Affects Versions: 3.3.1
Reporter: Geoffrey De Smet
Here's the proof:
http://fisheye.jboss.org/browse/Hibernate/core/tags/hibernate-3.3.1.GA/co...
contains the lines (44-45):
registerColumnType( Types.CLOB, "longtext" );
registerColumnType( Types.CLOB, 16777215, "mediumtext" );
registerColumnType( Types.CLOB, 65535, "text" );
But the sources jar downloaded from
http://repository.jboss.org/maven2/org/hibernate/hibernate-core/3.3.1.GA/...
file
org\hibernate\dialect\MySQLDialect.java
so on my pc
C:\Documents and Settings\gds\.m2\repository\org\hibernate\hibernate-core\3.3.1.GA\hibernate-core-3.3.1.GA-sources.jar!\org\hibernate\dialect\MySQLDialect.java
has these lines (66-68) instead:
registerColumnType( Types.CLOB, "longtext" );
// registerColumnType( Types.CLOB, 16777215, "mediumtext" );
// registerColumnType( Types.CLOB, 65535, "text" );
It's not just some copyright stuff that been added (giving it different line numbers), some lines are clearly commented out.
Maybe untagged changes happened in other files too?
--
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
13 years, 3 months
[Hibernate-JIRA] Created: (HHH-6719) org.hibernate.sql.Template prefixes all ` and " with the generated HQL alias so not all SQL strings in formulas are generated correctly when we want to use ` in column name/table names
by Krasimir Chobantonov (JIRA)
org.hibernate.sql.Template prefixes all ` and " with the generated HQL alias so not all SQL strings in formulas are generated correctly when we want to use ` in column name/table names
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-6719
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6719
Project: Hibernate Core
Issue Type: Bug
Components: core
Environment: hibernate 3.3.2.GA and up
Reporter: Krasimir Chobantonov
Using the following SQL query in descriminator formula
(select distinct ldt.`TYPE_NAME` from `LIST_DATA_TYPE` ldt where ldt.`LIST_DATA_TYPE_ID` = `LIST_DATA_TYPE_ID`)
result it
(select distinct ldt.listdata0_."TYPE_NAME" from listdata0_."SF_LIST_DATA_TYPE" ldt where ldt.listdata0_."LIST_DATA_TYPE_ID" = listdata0_."LIST_DATA_TYPE_ID")
instead of
(select distinct ldt."TYPE_NAME" from "SF_LIST_DATA_TYPE" ldt where "LIST_DATA_TYPE_ID" = listdata0_."LIST_DATA_TYPE_ID")
The quotes are needed so that the same SQL will work on Oracle and Postgresql (where the later expects all lower case table names/ column names if not using quotes)
Possible solution:
in org.hibernate.sql.Template change the code on line 180
from
if (isOpenQuote) {
to
if (isOpenQuote && !inFromClause && (previousToken == null || !previousToken.endsWith("."))) {
note that the previousToken is a new variable that tracks previous tokens.
Using this if clause will not place a prefix on the table because of !inFromClause and it will not add prefix on all ldt. places - e.g. when we already specified to which table the column that we refers belongs to.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 3 months
[Hibernate-JIRA] Created: (HHH-6721) The "invalid column name" error message is misleading when the real problem is that there is a bean field that doesn't have a matching column name in the query.
by HappyEngineer (JIRA)
The "invalid column name" error message is misleading when the real problem is that there is a bean field that doesn't have a matching column name in the query.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-6721
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6721
Project: Hibernate Core
Issue Type: Improvement
Components: query-sql
Environment: hibernate-core 3.6.6.Final. Oracle database.
Reporter: HappyEngineer
Priority: Minor
If I have the following bean:
@Entity
public class Foobar
{
@Id
private int id;
private String name;
}
and the following unit tests:
@PersistenceContext(unitName = "reports2") private EntityManager em;
@Test
public void testGoodColumnName() {
em.createNativeQuery("select 1 id, 'name' name from dual",Foobar.class)
.getResultList();
}
@Test
public void testBadColumnName() {
em.createNativeQuery("select 1 id, 'name' name2 from dual",Foobar.class)
.getResultList();
}
the first unit test will succeed, but the second will fail with an "Invalid column name" SQLException.
The reason for this is that the "name" field in the class doesn't have a corresponding "name" column in the query.
Because I'm using Oracle I'm used to getting error messages which are unhelpful because they don't mention the column name that is invalid when I write an invalid query. As a result I spent a lot of time trying to figure out why the query worked when run in Squirrel SQL but not when run with Hibernate. Of course, I eventually figured out that the problem was the one I outlined above.
It would have been much simpler for me if the error message had simply said something like "The query does not specify a column which corresponds to the 'name' field of bean com.foo.Foobar.".
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 3 months
[Hibernate-JIRA] Created: (HHH-3930) one-to-one causes redundant select query
by Martijn Dashorst (JIRA)
one-to-one causes redundant select query
----------------------------------------
Key: HHH-3930
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3930
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Reporter: Martijn Dashorst
@Entity
public class Address {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToOne(mappedBy = "address")
private Customer customer;
}
@Entity
public class Customer {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private Address address = new Address();
public Long getId() {
return id;
}
public Address getAddress() {
return address;
}
}
This mapping causes 2 instead of the expected 1 query to retrieve a Customer and its Address from the db:
select * from Customer customer0_ left outer join Address address1_ on customer0_.address_id=address1_.id where customer0_.id=?
select * from Customer customer0_ left outer join Address address1_ on customer0_.address_id=address1_.id where customer0_.address_id=?
Changing the mapping to a LAZY fetch type:
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private Address address = new Address();
Causes 3 select queries instead of the expected 2 queries to retrieve a Customer (and its Address) from the db:
select * from Customer customer0_ where customer0_.id=?
select * from Address address0_ left outer join Customer customer1_ on address0_.id=customer1_.address_id where address0_.id=?
select * from Customer customer0_ where customer0_.address_id=?
The third select is superfluous because the relationship is already completely known: you already have the customer, so why not just set it on the address entity?
Making the address field in Customer a @ManyToOne doesn't make a difference.
Making the customer field in Address a @OneToMany does remove the extra select, but forces our model to change the relationship from Customer to List<Customer> where we *know* there'll be only 1 element.
Apparently Hibernate can figure out the reverse relationship with a @ManyToOne - @OneToMany without the need for additional queries, can't this be extended to @OneToOne bidirectional relationships as well?
--
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
13 years, 3 months
[Hibernate-JIRA] Created: (HHH-6746) ConcurrentModificationException in org.hibernate.connection.DriverManagerConnectionProvider.close()
by Nikita D (JIRA)
ConcurrentModificationException in org.hibernate.connection.DriverManagerConnectionProvider.close()
---------------------------------------------------------------------------------------------------
Key: HHH-6746
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6746
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.3
Reporter: Nikita D
Priority: Minor
A java.util.ConcurrentModificationException is thrown intermittently from DriverManagerConnectionProvider.close(). This is the stacktrace:
{code}
java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
at java.util.AbstractList$Itr.next(AbstractList.java:343)
at org.hibernate.connection.DriverManagerConnectionProvider.close(DriverManagerConnectionProvider.java:175)
at org.hibernate.impl.SessionFactoryImpl.close(SessionFactoryImpl.java:965)
at [my code]
{code}
All the other methods in that class synchronize their access to the pool ArrayList, but close() does not (even though it iterates over the list).
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 3 months