[Hibernate-JIRA] Created: (HHH-3227) Oracle's connect by syntax is mishandled when used with Filter
by Kyrill Alyoshin (JIRA)
Oracle's connect by syntax is mishandled when used with Filter
--------------------------------------------------------------
Key: HHH-3227
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3227
Project: Hibernate3
Issue Type: Bug
Components: query-sql
Affects Versions: 3.2.5
Environment: Hibernaet 3.2.5.GA, Oracle 10g.
Reporter: Kyrill Alyoshin
Basically, I have a filter definition on a class (via annotation), here it is:
@Filter(name = "limitInvoicesByAccountHolderHierarchy",
condition = "CHRG_ACCT_ID in (" +
"select ca1.chrg_acct_id from cv_chrg_acct ca1 " +
"inner join cv_org_unit og1 on ca1.acct_hldr_id = og1.org_unit_id " +
"where og1.org_unit_id in (" +
"select og2.org_unit_id from cv_org_unit og2 " +
"start with og2.org_unit_id = :root " +
" connect by prior og2.org_unit_id = og2.hier_par_org_unit_id" +
')' +
')'
It contains Oracle's "connect by" clause. Here is the SQL statement that Hibernate generates when trying to query invoices with the filter enabled:
Hibernate:
/*
from
Invoice */ select
invoice0_.inv_id as inv1_31_,
......
from
CV_INV invoice0_
where
invoice0_.CHRG_ACCT_ID in (
select
ca1.chrg_acct_id
from
cv_chrg_acct ca1
inner join
cv_org_unit og1
on ca1.acct_hldr_id = og1.org_unit_id
where
og1.org_unit_id in (
select
og2.org_unit_id
from
cv_org_unit og2 invoice0_.start invoice0_.with og2.org_unit_id = ? invoice0_.connect
by
invoice0_.prior og2.org_unit_id = og2.hier_par_org_unit_id
)
)
Even though the documentation states that the condition of the filter is pure SQL (which is great!), it still does not pass SQL verbatim but is actually trying to pre-process the following words: start, with, connect, prior.
Is there an easy work around to make Oracle10gDialect recognize these words?
Thanks a lot for looking into this!
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-5587) InheritanceType.TABLE_PER_CLASS crashs when the primary classes have properties with the same name and different values ONLY USING JTA PERSISTENT-UNIT
by Mauricio Chamati (JIRA)
InheritanceType.TABLE_PER_CLASS crashs when the primary classes have properties with the same name and different values ONLY USING JTA PERSISTENT-UNIT
------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-5587
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5587
Project: Hibernate Core
Issue Type: Bug
Components: core, entity-manager
Affects Versions: 3.5.6
Environment: Postgre 8.4, Hibernate 3.5.6-Final, Maven 2, Glassfish 3.01, JPA 2.0, EJB 3.1
Reporter: Mauricio Chamati
I am trying to retrieve a list of Products (Entity). Each product has a list of a pair Attribute/Value mapped as follows:
@OneToMany(cascade = javax.persistence.CascadeType.ALL, mappedBy="product", fetch=FetchType.EAGER)
@MapKey(name="attribute")
private Map<Attribute, Value<?>> attributes = new HashMap<Attribute, Value<?>>();
As this value can be of many types, I used "InheritanceType.TABLE_PER_CLASS" in the "Value.class".
Everything runs OK for LOCAL_RESOURCE persistent-unit.
But, running into the container using JTA that does not work. It gives the database error: "UNION types x and y cannot be matched." (being x and y types like numeric or date).
The generated query for JTA is something like this (I shorten it):
select *
from (
select id, attribute, product, value
from value_datetime
union all
select id, attribute, product, value
from value_decimal
union all
select id, attribute, product, value
from value_integer
) attributes
where product = ?
And of course, the values won't match.
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-5586) PersistentClass.checkColumnDuplication does not honor @Column.table
by Jürgen (JIRA)
PersistentClass.checkColumnDuplication does not honor @Column.table
-------------------------------------------------------------------
Key: HHH-5586
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5586
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Environment: hibernate 3.3.1.GA packaged with jboss 5.1.0.GA
Reporter: Jürgen
similar column names in main and a secondary table triggers MappingException:
org.hibernate.MappingException: Repeated column in mapping for entity
in case of javax.persistence.InheritanceType.TABLE_PER_CLASS
seems to me as if org.hibernate.mapping.PersistentClass.checkColumnDuplication(Set, Iterator) does not consider javax.persistence.Column.table() value for duplication check.
{code}
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: com.example.AAAX column: col1 (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:670)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:692)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:714)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:468)
at org.hibernate.mapping.UnionSubclass.validate(UnionSubclass.java:63)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1135)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1320)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
...
{code}
Following entity model (nevermind the inheritance, it a legacy db mapping)
{code}
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
abstract class A {}
@Entity
@Table(name="AA")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorFormula(value="discriminator")
abstract class AA extends A {
@Column(name = "col1")
protected String col1;
}
@Entity
@SecondaryTable(name = "T", pkJoinColumns=@PrimaryKeyJoinColumn(name="a"))
abstract class AAA extends AA {
@Column(name = "col1", table="T")
protected String Tcol1;
}
@Entity
@DiscriminatorValue(value="AAX")
public class AAAX extends AAA {
}
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-2402) HQL generates inner join when selecting a specific attribute that is linked to another entity
by Peter Mutsaers (JIRA)
HQL generates inner join when selecting a specific attribute that is linked to another entity
---------------------------------------------------------------------------------------------
Key: HHH-2402
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2402
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.2
Environment: Oracle 9i, affects ONLY version 3.2.2, was still working OK in version 3.2.1 and before.
Reporter: Peter Mutsaers
Priority: Critical
Mapping (note the lazy='false', it is essential to cause the problem):
<class name='Currency' lazy='false'>
....
</class>
<class name='Asset'>
<id name='id' ... </id>
<many-to-one name='currency' class='Currency' fetch='select'/>
</class>
The following HQL query: "select a.id, a.currency from Asset a"
used to generate a query on the Asset table, and subsequently generates separate queries on the Currency table.
Since version 3.2.2, this generates an inner join on Asset with Currency.
Now many Assets may have a NULL currency, so we do not get all records anymore!
This breaks logic and queries all over the place for us.
We can't go back to 3.2.1 due to other bugs that had been solved in 3.2.2.
The query "from Asset a" still works OK and as before, i.e. it makes the select only on the Asset table and afterwards fetches the Currency with individual selects.
I fear that an optimization has been made that has this negative side effect.
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-3510) Sybase - Timestamp not being translated to the built-in database function
by Juraci Paixao Krohling (JIRA)
Sybase - Timestamp not being translated to the built-in database function
-------------------------------------------------------------------------
Key: HHH-3510
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3510
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.2.4.sp1
Environment: Branch_3_2_4_SP1_CP and Sybase 15
Reporter: Juraci Paixao Krohling
Test Case: ComponentTest#testComponentQueries
Hibernate query "from Employee e where e.person = ('steve', current_timestamp)" should have translated "current_timestamp" to "getdate()" [1]:
14:49:11,087 DEBUG SQL:424 - select employee0_.ID as ID1_, employee0_.HIRE_DATE as HIRE2_1_, employee0_.name as name1_, employee0_.dob as dob1_, employee0_.value1 as value5_1_, employee0_.value2 as value6_1_ from T_EMP employee0_ where employee0_.name='steve' and employee0_.dob=current_timestamp
14:49:11,535 WARN JDBCExceptionReporter:77 - SQL Error: 207, SQLState: ZZZZZ
14:49:11,536 ERROR JDBCExceptionReporter:78 - Invalid column name 'current_timestamp'.
[1] SybaseDialect, line 58: registerFunction( "current_timestamp", new NoArgSQLFunction("getdate", Hibernate.TIMESTAMP) );
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-5584) Need method Dialect to apply hibernate type over-rides.
by Justin Sands (JIRA)
Need method Dialect to apply hibernate type over-rides.
-------------------------------------------------------
Key: HHH-5584
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5584
Project: Hibernate Core
Issue Type: Improvement
Components: core
Affects Versions: 3.6.0.CR1
Environment: 3.6.0.CR1, postgresql
Reporter: Justin Sands
Priority: Minor
There is currently no way to register hibernate type over-rides simply by extending the Dialect object.
This forces applications to inject custom bootstrapping code, where a simple property change (the dialect) would suffice.
This could be easily overcome by having the SessionFactory interrogate the dialect to see if it contains any substitutions.
public class SessionFactoryImpl {
public SessionFactoryImpl(...) {
if (getDialect().getTypeOverrides() != null) {
for (BasicType overrideType : getDialect().getTypeOverrides())
cfg.registerTypeOverride(overrideType);
}
}
}
public abstract class Dialect {
// basic implementation,
public List<BasicType> getTypeOverrides() {
return null;
}
}
--
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, 8 months
[Hibernate-JIRA] Commented: (HHH-892) HQL parser does not resolve alias in ORDER BY clause
by Gail Badner (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-892?page=co... ]
Gail Badner commented on HHH-892:
---------------------------------
I just checked a fix for this issue into trunk. It would be great if some folks could give it a try to see if it works.
I've included a new method, Dialect.replaceResultVariableInOrderByClauseWithPosition() (yes, I know it's kinda long), to indicate that a select expression position should be used instead of the "result variable". A "result variable" corresponds to the alias(es) assigned to an HQL select expression.
By default, false is reeturned. Dialects that require the position should override this method.
I don't know of any dialects that need to override this method. I'll check the test results for the dialects we test, and make any necessary corrections tomorrow. I'll need input from others about dialects we do not regularly use for testing.
Thanks,
Gail
> HQL parser does not resolve alias in ORDER BY clause
> -----------------------------------------------------
>
> Key: HHH-892
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-892
> Project: Hibernate Core
> Issue Type: Bug
> Components: query-hql
> Affects Versions: 3.5.4, 3.6.0.Beta1
> Environment: Hibernate 3.0.5, MySQL, Tomcat
> Reporter: Guido Laures
> Assignee: Gail Badner
> Fix For: 3.6.x
>
> Attachments: HHH-892.patch, HibernateHavingAliasTest.java
>
>
> When using an alias for an ORDER BY clause this is not always correctly resolved. Example:
> SELECT SUM(A.x) AS mySum FROM MyClass AS A GROUP BY A.y ORDER BY mySum
> does not work because "mySum" is not resolved in the ORDER BY clause which results in an exception telling that mySum is an unknown column.
> Workaround (not to say "hack") is using:
> SELECT SUM(A.x) AS mySum FROM MyClass AS A GROUP BY A.y ORDER BY col_0_0_
--
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, 8 months