[Hibernate-JIRA] Commented: (HHH-1582) PostInsertListener + "post-commit-insert"
by Daniel Gredler (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1582?page=c... ]
Daniel Gredler commented on HHH-1582:
-------------------------------------
@Steve: Of course, you could just go ahead and resolve the issue rather than playing musical chairs with it ;-) *ducks*
> PostInsertListener + "post-commit-insert"
> -----------------------------------------
>
> Key: HHH-1582
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1582
> Project: Hibernate Core
> Issue Type: Bug
> Affects Versions: 3.1.2
> Reporter: Daniel Gredler
> Assignee: Emmanuel Bernard
> Original Estimate: 3 hours
> Remaining Estimate: 3 hours
>
> I'm using a custom PostInsertEventListener mapped to the "post-commit-insert" event to process domain objects. However, PostInsertEventListener's onPostInsert(PostInsertEvent) is getting called even when the insert was not successful (ie, due to a unique constraint in the database or some such). It looks to me like Hibernate should either a) not invoke the event listener if the insert failed or b) provide state (perhaps in the form of a boolean indicating success/failure). Personally I'd rather the method not be called on failure, but there may be use cases out there for the second option.
> As an example, it looks like Hibernate's own LuceneEventListener will add a domain object to the index in onPostInsert(PostInsertEvent) even if the insert failed.
> Note that this problem also seems to exist in EntityDeleteAction and EntityUpdateAction (which would mean that Hibernate's LuceneEventListener removes domain objects from the Lucene index even if the delete 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
16 years, 3 months
[Hibernate-JIRA] Created: (ANN-651) Bad SQL generated when using the @OrderBy annotation
by Eyal Lupu (JIRA)
Bad SQL generated when using the @OrderBy annotation
----------------------------------------------------
Key: ANN-651
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-651
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.0.ga
Environment: Hibernate Annotations 3.3.0.GA
Hibernate 3.2.5
EntityManager 3.3.1.GA
Hibernate Validator 3.0.0.GA
Oracle 10g
Reporter: Eyal Lupu
Attachments: orderBy-bug-test-case.zip
When upgrading to the versions above a code which works for months now stopped working, the reason is that Hibernate generates a bad SQL statment.
Attached is a test case:
Having the following classes
Parent
/ \
Child1 Child2
The parent has a property named 'elementType'. Child1 has a list of Child2 (its sibling) which is ordered using the
@OrderBy("elementType") annotation. When fetching a Child1 instance, using the EntityManager.find(...) method, Hibernate generates an
invalid SQL:
Hibernate: /* load bug.Child1 */ select child1x0_.ID as ID0_1_, child1x0_.ELEMENT_TYPE as ELEMENT3_0_1_, elements1_.PARENT_ID as PARENT4_3_, elements1_.ID as ID3_, elements1_.ID as ID0_0_, elements1_.ELEMENT_TYPE as ELEMENT3_0_0_, elements1_.PARENT_ID as PARENT4_0_0_ from BUG_TST child1x0_ left outer join BUG_TST elements1_ on child1x0_.ID=elements1_.PARENT_ID where child1x0_.ID=? and child1x0_.DTYPE='Child1' order by BUG_TST.ELEMENT_TYPE asc
The error is in the order by clause, you can't use the table name if you gave it an alias - you should use the alias.
* If I move the 'elementType' property down to Child2 it works!
*If I remove the @OrderBy it also works
-- It is hard to know if this is an Hibernate core or Hibernate annotation bug.
This is the exception:
Caused by: org.hibernate.exception.SQLGrammarException: could not load an entity: [bug.Child1#1]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1874)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3044)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:175)
... 1 more
Caused by: java.sql.SQLException: ORA-00904: "BUG_TST"."ELEMENT_TYPE": invalid identifier
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:799)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1038)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:839)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1133)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
... 13 more
-- Attached is a test case
--
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, 3 months
[Hibernate-JIRA] Updated: (HHH-1582) PostInsertListener + "post-commit-insert"
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1582?page=c... ]
Steve Ebersole updated HHH-1582:
--------------------------------
Fix Version/s: (was: 3.3.x)
Tired of moving this around...
> PostInsertListener + "post-commit-insert"
> -----------------------------------------
>
> Key: HHH-1582
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1582
> Project: Hibernate Core
> Issue Type: Bug
> Affects Versions: 3.1.2
> Reporter: Daniel Gredler
> Assignee: Emmanuel Bernard
> Original Estimate: 3 hours
> Remaining Estimate: 3 hours
>
> I'm using a custom PostInsertEventListener mapped to the "post-commit-insert" event to process domain objects. However, PostInsertEventListener's onPostInsert(PostInsertEvent) is getting called even when the insert was not successful (ie, due to a unique constraint in the database or some such). It looks to me like Hibernate should either a) not invoke the event listener if the insert failed or b) provide state (perhaps in the form of a boolean indicating success/failure). Personally I'd rather the method not be called on failure, but there may be use cases out there for the second option.
> As an example, it looks like Hibernate's own LuceneEventListener will add a domain object to the index in onPostInsert(PostInsertEvent) even if the insert failed.
> Note that this problem also seems to exist in EntityDeleteAction and EntityUpdateAction (which would mean that Hibernate's LuceneEventListener removes domain objects from the Lucene index even if the delete 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
16 years, 3 months
[Hibernate-JIRA] Commented: (ANN-391) SecondaryTables not recognized when using JOINED inheritance
by mike wray (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-391?page=co... ]
mike wray commented on ANN-391:
-------------------------------
We've used a different appraoch to workaround this.
Map the secondary table to its own entity, then reference that entity from the first entity using a cascading @onetoone.
<code>
@Entity
public class Primary.....
private Second second;
@OneToOne(mappedBy="primary", cascade=CascadeType.ALL)
private Second getSecond () {
if(this.second== null){
this.second= new Second();
this.second.setPrimary(this);
}
return this.second;
}
private void setSecond (Second value) {
this.second= value;
}
@Transient
public String getExt1() {
return getSecond().getExt1();
}
public void setExt1(String ext1) {
getSecond().setExt1(ext1);
}
@Entity
public class Second....
private Primary primary;
@OneToOne
public Primary getPrimary () {
return this.primary;
}
public void setPrimary (Primary value) {
this.primary= value;
}
..
</code>
You could probably further encapsulate by having Second as a private inner class, haven't tried that - i'm not sure it's allow by jpa.
These mappings cause an Outer Join query with SECOND, which is exactly what a @SecondaryTable would do.
Creation of a new PRIMARY only inserts a new SECOND row if values are explicitly set for Extension properties, which is exactly what @SecondaryTable would do.
CascadeType.ALL means SECOND row is flushed to database at same time as PRIMARY , which is exactly what @SecondaryTable would do.
Internal implementation is hidden. The object model and the physical model remain the same.
A possible difference:If all properties on SECOND are set to null, SECOND row is not deleted (would @SecondaryTable do that?? - I'm not sure)
> SecondaryTables not recognized when using JOINED inheritance
> ------------------------------------------------------------
>
> Key: ANN-391
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-391
> Project: Hibernate Annotations
> Issue Type: Bug
> Components: binder
> Affects Versions: 3.1.0.beta10, 3.2.0.cr1
> Environment: Hibernate 3.2.0CR1; db is irrelevant, as the buildSessionFactory() fails.
> Reporter: Sebastian Kirsch
> Attachments: TestSecondaries.java, TestSecondaries.java, TestSecondaries.java
>
>
> The Configuration doesn't recognize secondary tables of a super class.
> Calling AnnotationConfiguration.buildSessionFactory fails, claiming that the secondary table used in the super class cannot be found in the subclass.
> Adding the secondary table to the subclass doesn't help either.
> See attached JUnit test case.
--
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, 3 months
[Hibernate-JIRA] Created: (HHH-2281) CLONE -Calling Session.connection() generates java.lang.IllegalArgumentException: interface org.hibernate.jdbc.ConnectionWrapper is not visible from class loader
by Sergey Polzunov (JIRA)
CLONE -Calling Session.connection() generates java.lang.IllegalArgumentException: interface org.hibernate.jdbc.ConnectionWrapper is not visible from class loader
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-2281
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2281
Project: Hibernate3
Type: Bug
Versions: 3.2.1
Environment: Hibernate checked out from trunk; revision 10717
Reporter: Sergey Polzunov
Calling Session.connection() always generates an exception. Here is the stacktrace I get from the attached test case:
Exception in thread "main" java.lang.IllegalArgumentException: interface org.hibernate.jdbc.ConnectionWrapper is not visible from class loader
at java.lang.reflect.Proxy.getProxyClass(Proxy.java:353)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)
at org.hibernate.jdbc.BorrowedConnectionProxy.generateProxy(BorrowedConnectionProxy.java:56)
at org.hibernate.jdbc.ConnectionManager.borrowConnection(ConnectionManager.java:163)
at org.hibernate.jdbc.JDBCContext.borrowConnection(JDBCContext.java:111)
at org.hibernate.impl.SessionImpl.connection(SessionImpl.java:359)
at TestSession.main(TestSession.java:16)
Changing the Connection.class.getClassLoader() to BorrowedConnectionProxy.class.getClassLoader() on line 57 in the generateProxy() method solves the problem. I am not very familiar with class loaders so I don't know if this is likeley to cause other problems elsewhere. Removing the ConnectionWrapper.class from the PROXY_INTERFACES array in the org.hibernate.jdbc.BorrowedConnectionProxy also solves the problem, but I guess it was added for a reason.
--
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, 3 months
[Hibernate-JIRA] Created: (ANN-780) length attribute missing on @Index annotation
by Xavier Sautejeau (JIRA)
length attribute missing on @Index annotation
---------------------------------------------
Key: ANN-780
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-780
Project: Hibernate Annotations
Issue Type: Improvement
Affects Versions: 3.4.0.GA
Reporter: Xavier Sautejeau
Using MySQL, one can do something like :
CREATE TABLE test(name TEXT, INDEX(name(255))
which creates a test table with an Index of length 255 on name.
Using Oracle one can use function based index to achieve similar result (create an index based on part of a column)
I am not 100% sure of the syntax, but it should look like
CREATE INDEX name_index ON test(SUBSTR(name,255))
However using Hibernate annotations, if one can specify that a column is to be used as an index, it seems like there is no way to specify the length of the index.
Therefore, (at least with MySQL) the column length is used for the index length.
But with some RDBMS, the index length can only go so far (for example 256 on MySQL), forcing you not to use the given column as an index since you cannot use Hibernate to tell it not to use the full length of the column for indexing.
The length attribute should be added to the @Index annotation and the appropriate index should be created for the various combinations of drivers/dialects supporting this feature
--
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, 3 months
[Hibernate-JIRA] Created: (HHH-2933) DialectFactory dialects should be in a properties file
by Mikael Kopteff (JIRA)
DialectFactory dialects should be in a properties file
------------------------------------------------------
Key: HHH-2933
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2933
Project: Hibernate3
Issue Type: Improvement
Components: core
Affects Versions: 3.2.5
Reporter: Mikael Kopteff
Currently the DialectFactory has the static attribute MAPPERS, that hold the dialects. If the dialect is not found, Hibernate will throw an exception. There is already an TODO tag, set for this.So, could this be possibly done, so that the values really are a) in a properties file or b)additions could be made to the map programmaticaly by users.
This would be more flexible for advanced users, that work with experimental jdbc drivers(that don't return a standard name for the database).
The current trunk version of DialectFactory:
// TODO : this is the stuff it'd be nice to move to a properties file or some other easily user-editable place
private static final Map MAPPERS = new HashMap();
static {
MAPPERS.put( "HSQL Database Engine", new VersionInsensitiveMapper( "org.hibernate.dialect.HSQLDialect" ) );
MAPPERS.put( "H2", new VersionInsensitiveMapper( "org.hibernate.dialect.H2Dialect" ) );
MAPPERS.put( "MySQL", new VersionInsensitiveMapper( "org.hibernate.dialect.MySQLDialect" ) );
etc.....
--
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, 3 months
[Hibernate-JIRA] Commented: (HHH-1483) MySQL5: No Dialect mapping for JDBC type: -1
by Andy Schlaikjer (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1483?page=c... ]
Andy Schlaikjer commented on HHH-1483:
--------------------------------------
using the following derived Dialect works for me (using Hibernate 3.2.6.ga):
public class MySQL5Dialect extends org.hibernate.dialect.MySQL5Dialect
{
public MySQL5Dialect()
{
super();
// register additional hibernate types for default use in scalar sqlquery type auto detection
registerHibernateType(Types.LONGVARCHAR, Hibernate.TEXT.getName());
}
}
thanks vaibhavi and other commentors!
> MySQL5: No Dialect mapping for JDBC type: -1
> --------------------------------------------
>
> Key: HHH-1483
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1483
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1.2
> Environment: MySQL 5.0.18-nt
> Reporter: Sergey Vladimirov
> Priority: Minor
>
> MySQL5: No Dialect mapping for JDBC type: -1
> SELECT answpos,answer FROM votes_answers WHERE question=? ORDER BY answpos
> mysql> describe votes_answers;
> +----------+---------+------+-----+---------+-------+
> | Field | Type | Null | Key | Default | Extra |
> +----------+---------+------+-----+---------+-------+
> | question | int(11) | NO | MUL | | |
> | answpos | int(11) | NO | | | |
> | answer | text | YES | | NULL | |
> +----------+---------+------+-----+---------+-------+
> mysql> describe temp;
> +---------+---------+------+-----+---------+-------+
> | Field | Type | Null | Key | Default | Extra |
> +---------+---------+------+-----+---------+-------+
> | answpos | int(11) | NO | | 0 | |
> | answer | text | YES | | NULL | |
> +---------+---------+------+-----+---------+-------+
> Please, let me know what to add to MySQL5Dialect :)
> Will it be ok to add? :
> registerColumnType( Types.LONGVARCHAR, "text" );
--
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, 3 months