[Hibernate-JIRA] Created: (HHH-3733) Introduce an annotation to disable ad-hoc null semantic of Hibernate components
by Vladimir Kovalyuk (JIRA)
Introduce an annotation to disable ad-hoc null semantic of Hibernate components
-------------------------------------------------------------------------------
Key: HHH-3733
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3733
Project: Hibernate Core
Issue Type: Improvement
Components: core
Reporter: Vladimir Kovalyuk
see http://forums.hibernate.org/viewtopic.php?t=993972
For the model
@Entity
public class Person {
private Address name = new Address();
...
@Embedded Address getAddress() {}
}
@Embeddable
public class Address {
public String getCity() {}
public String getStreet() {}
}
the following xhtml excerpt causes NPE constantly when editing a person which address properties hasn't been filled in yet
<h:inputText value="#{person.address.city}" />
I suggest introducing an annotation @Static which could be applied to Address class and lead to disabling null ad-hoc semantic on its instances.
For some environments such as user interface this may be considered as the default behavior. I suggest introducing an Hibernate configuration parameter which would switch off the semantic.
I would propose to consider embeddable classes as static mixins from OO design, not as just limited entities without identity. This point of view explains that embedded instance is a part of entity so it's lifecycle is the same as the entity's lifecycle. Thus constant presence of embeddable instance (property is never null) is the default behavior. Thus configuration parameter is "must have", not the thing which is "nice to have".
>From the other hand null ad-hoc semantic is like dynamic mixins. So it would be nice to have a @Dynamic annotation to force this semantic for some components.
--
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-5040) SQLQuery fails with auto-discovery of result set metadata and aliased columns
by Chris Wilson (JIRA)
SQLQuery fails with auto-discovery of result set metadata and aliased columns
-----------------------------------------------------------------------------
Key: HHH-5040
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5040
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.2
Environment: 3.3.2 GA, MySQL Connector/J 5.0.
Reporter: Chris Wilson
Attachments: HibernateSqlQueryAliasTest.java
Hibernate assumes that the column name returned by ResultSetMetaData#getColumnName(int) is the name it can use to extract the data from the ResultSet. However, if the SQLQuery uses column aliases, then this will fail here:
{code|title=Stack Trace}
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2235)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
at org.hibernate.loader.Loader.list(Loader.java:2124)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1723)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
at org.wfp.rita.test.hibernate.HibernateSqlQueryAliasTest.testFailingWithAliases(HibernateSqlQueryAliasTest.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.wfp.rita.test.base.HibernateTestBase.runTestMethod(HibernateTestBase.java:204)
at org.wfp.rita.test.base.HibernateTestBase.runTest(HibernateTestBase.java:117)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.sql.SQLException: Column 'id' not found.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
at com.mysql.jdbc.ResultSetImpl.findColumn(ResultSetImpl.java:1145)
at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2814)
at org.hibernate.type.IntegerType.get(IntegerType.java:51)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:184)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:210)
at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.extract(CustomLoader.java:497)
at org.hibernate.loader.custom.CustomLoader$ResultRowProcessor.buildResultRow(CustomLoader.java:443)
at org.hibernate.loader.custom.CustomLoader.getResultColumnOrRow(CustomLoader.java:340)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:629)
at org.hibernate.loader.Loader.doQuery(Loader.java:724)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2232)
... 26 more
{code}
Hibernate appears to support auto-discovery of result set columns, notwithstanding bug
[HHH-436|http://opensource.atlassian.com/projects/hibernate/browse/HHH-436] which was closed as fixed. No QueryException is thrown if the returns of the query have not been defined.
Instead, SQLQueryImpl.verifyParameters() sets SQLQueryImpl.autodiscovertypes, which ends up in
QueryParameters.autodiscovertypes, which CustomLoader.doQuery() passes to CustomLoader.getResultSet(), which then calls CustomLoader.autoDiscoverTypes(), which calls
ScalarResultColumnProcessor.performDiscovery().
performDiscovery() calls ResultSetMetaData#getColumnName() to retrieve each column name from the result set, which ends up in CustomLoader.ResultRowProcessor, where ScalarResultColumnProcessor.extract() tries to use it to extract data from the result set. Because the name doesn't match the actual alias used in the result set, this fails with the exception given above.
[JDBC 4.0 Specification|http://jcp.org/aboutJava/communityprocess/final/jsr221/inde...] does not specify whether ResultSetMetaData.getColumnName() should return the name of the underlying column, or the name of the alias. It seems bizarre to me that it returns a value that cannot be passed to ResultSet.getObject(String). However, both MySQL and H2 take the position that we should call ResultSetMetaData.getColumnLabel() instead to get the name that can be used on the ResultSet:
* [MySQL bug 21379|http://bugs.mysql.com/bug.php?id=21379]
* [MySQL bug 21596|http://bugs.mysql.com/bug.php?id=21596]
* [H2 mailing list discussion|http://www.mail-archive.com/h2-database@googlegroups.com/msg00...]
The fix would appear to be modifying ScalarResultColumnProcessor.performDiscovery() (or CustomLoader.Metadata.getColumnName()) so that it calls getColumnLabel() instead of getColumnName(). The workaround is to explicitly specify column aliases with SQLQuery.addScalar().
Test case 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: (HSEARCH-383) Hibernate Search does not respect the @AccessType annotation in respect to @Id fields.
by Steven Knock (JIRA)
Hibernate Search does not respect the @AccessType annotation in respect to @Id fields.
--------------------------------------------------------------------------------------
Key: HSEARCH-383
URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-383
Project: Hibernate Search
Issue Type: Bug
Components: engine
Affects Versions: 3.1.1.GA, 3.1.0.GA
Environment: Hibernate 3.3.1.GA
Reporter: Steven Knock
Priority: Minor
Attachments: TestAccessTypeProblem.java
This occurs when indexing an Entity annotated as @IndexedEmbedded if the object that it is @ContainedIn is a proxy object that has not yet been loaded and if the @AccessType of the @Id of the proxy object has been overriden from field to property.
This is because Hibernate Search does not respect the @AccessType annotation, and so attempts to read the id of the parent object directly from the member variable, which is not initialised in the proxy and so returns 0 in the attached test case.
The problem is in:
org.hibernate.search.engine.DocumentBuilderIndexedEntity.checkDocumentId().
This results in a record in the Lucene index that has no reference to the containing instance. So, while the number of results is returned correctly, any attempt to actually retrieve the results and convert them into Hibernate objects fails.
--
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: (HSEARCH-402) Provide a ReaderProvider to cap the number of index reopenings to a fixed rate
by Sanne Grinovero (JIRA)
Provide a ReaderProvider to cap the number of index reopenings to a fixed rate
------------------------------------------------------------------------------
Key: HSEARCH-402
URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-402
Project: Hibernate Search
Issue Type: New Feature
Reporter: Sanne Grinovero
Assignee: Sanne Grinovero
Fix For: 3.2.0
It's often unneeded to recheck for an index update at very high frequency, which ends up to be a bottleneck in high-throughput applications
for an unneded guarantee of having latest version of index.
Setting a configurable period, let's say 5 seconds, will make this ReaderProvider reopen an IndexReader once each 5 seconds.
This can be done in background, removing the delay of checks from the call to openReader(); and enabling index warmup in future (Lucene 2.9 feature) in background.
When reopening in background the ratio will be fixed, i.e. the index will be reopened even if there's no request for a new IR.
This impl should manage the timer, but otherwise delegate to another implementation of ReaderProvider (defaulting to current default: SharingBufferReaderProvider) to optionally chain and provide the benefits of the other implementation.
--
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