[Hibernate-JIRA] Created: (HHH-2448) Generate identical column aliases among cluster
by Loïc LEFEVRE (JIRA)
Generate identical column aliases among cluster
-----------------------------------------------
Key: HHH-2448
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2448
Project: Hibernate3
Type: Improvement
Components: query-sql
Versions: 3.2.2
Environment: Hibernate version: 3.2.2, 2.1.8
Database: Oracle 9.2.0.8
Reporter: Loïc LEFEVRE
Attachments: report_1.txt, report_2.txt
Among our weblogic cluster (12 instances), we can see that a query can have different column aliases.
Although all seems correct, when regarding database reports like StatsPack or Spotlight we can see that because of these different aliases, the reports are wrong. Indeed, a resource consuming query can see its associated report properties (cpu usage, buffer gets, number of executions...) divided by the number of weblogic instances of our cluster (i.e. divided by 12) thus preventing us to pinpoint the queries to look at.
On a 3 instances cluster, we can see this report:
REPORT#1: one statement with a poor number of buffer gets/execution is reported splitted in 3, see the alias generated for column DTO.CREATION_DATE
for example
On a 4 instances cluster, we can see this report:
REPORT#2: one statement responsible of the latch free/cache buffers chains wait events splitted in 4, note the column alias generated fordeffcashcy0_.BEST_EXPECTED_CY
More than confusing the DBAs about the same query with n different "faces", our reports don't show us all the queries to look at: indeed, in our "Top 50 queries", a lot of them are duplicates! Also the memory required in the SGA to store the queries, the execution plan and so on is increased...
Finally, although the column aliases can have up to 30 characters under Oracle, the limit is set to 10, why?
--
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
11 years, 11 months
[Hibernate-JIRA] Created: (HHH-2308) Adjusting the Outer Join Predicate using Criteria Query
by Ben Grant (JIRA)
Adjusting the Outer Join Predicate using Criteria Query
-------------------------------------------------------
Key: HHH-2308
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2308
Project: Hibernate3
Type: New Feature
Components: query-criteria
Versions: 3.2.1
Environment: Linux Using MS SQLServer
Reporter: Ben Grant
I have two tables
Table A
||Col_1||Col_2||
|London| UK |
|Liverpool| UK |
| New York | USA |
Table B
||Col_1||Col_2|| Col_3||
| UK | Europe | 0
| USA | Americas | 1
Using the Criteria class, Restriction Class and FetchMode, Hibernate manages to create a query that looks like this
select distinct top 2000
this_.Col_1 as y0_, TableB3_.Col2 as y1_
from TableA this_
left outer join TableB TableB3_ on this_.Col_2= TableB3_.Col_1
where TableB3_.Col_3=1
When really i need the query to be like this
select distinct top 2000
this_.Col_1 as y0_, TableB3_.Col2 as y1_
from TableA this_
left outer join TableB TableB3_ on this_.Col_2= TableB3_.Col_1 AND TableB3_.Col_3=1
currently their isn't any know way for hibernate to adjust or apply filters within the join clause.
--
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
11 years, 11 months
[Hibernate-JIRA] Created: (HHH-2844) Limit and 'For Update' do not work on Oracle
by Michael Kopp (JIRA)
Limit and 'For Update' do not work on Oracle
--------------------------------------------
Key: HHH-2844
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2844
Project: Hibernate3
Issue Type: Bug
Components: query-sql
Affects Versions: 3.2.2
Reporter: Michael Kopp
Limits on oracle lead too:
select * from (select x.y as xy_1 from table x) where rownum <= 5
when doing a for update that leads too
select * from (select x.y as xy_1 from table x) where rownum <= 5 for update of x.y
The problem is that the x.y is invalid and not found within the temporary view and leads to an oracle error.
what would be valid is the name of the view column xy_1, meaning
select * from (select x.y as xy_1 from table x) where rownum <= 5 for update of xy_1
Actually this should be valid in all cases when doing a alias for update lock.
My Solution thus was to override the following in my own Oracle Dialect
public String applyLocksToSql(final String sql, final Map aliasedLockModes, final Map keyColumnNames)
{
final String s = new ForUpdateFragment(this, aliasedLockModes, keyColumnNames)
{
@Override
public ForUpdateFragment addTableAlias(final String alias)
{
// search for alias in sql
final int i = sql.indexOf(alias);
// check if the found string is followed by an ' as ' and thus has a column alias
if (i != -1 && sql.length() > (i + alias.length() + 4) && sql.substring(i + alias.length(), i + alias.length() + 4).equals(
" as "))
{
// use the column alias
return super.addTableAlias(sql.substring(i + alias.length() + 4, sql.indexOf(',',i + alias.length() + 4)));
}
return super.addTableAlias(alias);
}
}.toFragmentString();
return sql + s;
--
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
11 years, 11 months
[Hibernate-JIRA] Created: (HBX-939) Composite IDs and many-to-many relationships
by Markus Kramer (JIRA)
Composite IDs and many-to-many relationships
--------------------------------------------
Key: HBX-939
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-939
Project: Hibernate Tools
Issue Type: Bug
Affects Versions: 3.2beta9
Environment: Hibrnate 3.2.1, Postgresql 8.1.8
Reporter: Markus Kramer
Attachments: B.hbm.xml, testdb.sql
The detection of many-to-many relationships doesn't work correctly if the primary key of one of the involved tables consists of more than one field.
An example:
One of two tables (table 'A') of a many-to-many relationship has a primary key consisting of two attributes (id1 and id2).
The generated B.hbm.xml for the table 'B' contains this:
<set name="as" inverse="true" table="a_b">
<key>
<column name="b_id" not-null="true" />
</key>
<many-to-many entity-name="test.A">
<column name="a_id1" not-null="true" />
</many-to-many>
</set>
But there should be another entry for the referenced primary key:
<column name="a_id2" not-null="true" />
The SQL code for the used tables and the complete B.hbm.xml are attached.
--
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
11 years, 11 months
[Hibernate-JIRA] Created: (HHH-2847) THIS_"."NAME": invalid identifier when using createCriteria with addOrder
by Ashish Tiwari (JIRA)
THIS_"."NAME": invalid identifier when using createCriteria with addOrder
-------------------------------------------------------------------------
Key: HHH-2847
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2847
Project: Hibernate3
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.0.5
Environment: Oracle - 10.2.0
Reporter: Ashish Tiwari
We are using hibernate 3.0.5 and once a while I see following error getting generated due to incorrect SQL generated by hibernate:
Hibernate: select systembean0_.SYSTEMID as SYSTEMID12_0_, systembean0_.Version as Version12_0_, systembean0_.NAME as NAME12_0_, systembean0_.TYPE as TYPE12_0_, systembean0_.DESCRIPTION as DESCRIPT5_12_0_ from SDSYSTEM systembean0_ order by this_.NAME asc
- SQL Error: 904, SQLState: 42000
- ORA-00904: "THIS_"."NAME": invalid identifier
This normally works but occasionally we run into the issue mentioned above. I do not see alias "this_" in the sql query and I think that causes the error to happen. Issue is caused by alias not used consistently.
In normal case the generated SQL looks like following:
Hibernate: select this_.SYSTEMID as SYSTEMID7_0_, this_.Version as Version7_0_, this_.NAME as NAME7_0_, this_.TYPE as TYPE7_0_, this_.DESCRIPTION as DESCRIPT5_7_0_ from SDSYSTEM this_ order by this_.NAME asc
I am not sure what causes this problem. Has anyone else see similar problem earlier?
I appreciate any help with this. Below is other information:
Hibernate version: 3.0.5
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
name="com.avaya.coreservice.admin.toolkit.common.system.SystemBean"
table="SDSYSTEM">
<id name="uniqueId" type="java.lang.String">
<column name="SYSTEMID" length="50" not-null="true"/>
<generator class="uuid"/>
</id>
<version name="version" column="Version" />
<property
name="name"
type="java.lang.String">
<column name="NAME" length="512" not-null="true"/>
</property>
<property
name="type"
type="java.lang.String">
<column name="TYPE" length="50" not-null="false"/>
</property>
<property
name="description"
type="java.lang.String">
<column name="DESCRIPTION" length="1024" not-null="false"/>
</property>
<set name="resourceBeanSet">
<key>
<column name="SYSTEMID" length="50" not-null="false"/>
</key>
<one-to-many class="com.avaya.coreservice.admin.toolkit.common.resource.ResourceBean"/>
</set>
<set name="siteBeanSet" order-by="name asc">
<key>
<column name="SYSTEMID" length="50" not-null="false"/>
</key>
<one-to-many class="com.avaya.coreservice.admin.toolkit.common.site.SiteBean"/>
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
HibernateUtil.getSession().createCriteria(SystemBean.class)
.addOrder(Order.asc("name")).list();
Full stack trace of any exception that occurs:
N/A
Name and version of the database you are using:
Oracle - 10.2.0
The generated SQL (show_sql=true):
select systembean0_.SYSTEMID as SYSTEMID12_0_, systembean0_.Version as Version12_0_, systembean0_.NAME as NAME12_0_, systembean0_.TYPE as TYPE12_0_, systembean0_.DESCRIPTION as DESCRIPT5_12_0_ from SDSYSTEM systembean0_ order by this_.NAME asc
I appreciate any help with this.
Thanks,
--
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
12 years