[Hibernate-JIRA] Created: (EJB-278) Missing sequence or table on Oracle
by André Fernandes (JIRA)
Missing sequence or table on Oracle
-----------------------------------
Key: EJB-278
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-278
Project: Hibernate Entity Manager
Type: Patch
Components: EntityManager
Environment: JBoss 4.0.5.GA, Using JBoss SEAM and Oracle 9i, EJB/JPA annotations
Reporter: André Fernandes
Here we use a user "project_web" to access a "dbproject" schema.
The problem is, when Hibernate looks for the sequences, it looks in the user_sequences, but my user (project_web) don't have any sequences.
The solving is: when getting the sequence names (org.hibernate.dialect.Oracle9Dialect .getQuerySequencesString) use that:
select SEQUENCE_NAME from all_sequences where SEQUENCE_OWNER='DBPROJECT'
i.e. use the schema to look in the all_sequences.
Sorry for the bad english.
package org.hibernate.dialect;
public class Oracle9Dialect extends Dialect {
public String getQuerySequencesString() {
return "select sequence_name from user_sequences";
}
@GeneratedValue(generator="sqCoSeqProjeto", strategy=GenerationType.SEQUENCE)
@SequenceGenerator(name="sqCoSeqProjeto", sequenceName="sq_coseqprojeto", allocationSize=5)
--
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, 7 months
[Hibernate-JIRA] Created: (HHH-2382) DefaultLoadEventListener#onLoad throws exception when DelayedPostInsertIdentifier is set as an entity id
by Eelco Hillenius (JIRA)
DefaultLoadEventListener#onLoad throws exception when DelayedPostInsertIdentifier is set as an entity id
--------------------------------------------------------------------------------------------------------
Key: HHH-2382
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2382
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.1, 3.2.2, 3.2.0.ga
Reporter: Eelco Hillenius
DefaultLoadEventListener#onLoad has this code:
if ( idClass != null && ! idClass.isInstance( event.getEntityId() ) ) {
throw new TypeMismatchException(
"Provided id of the wrong type. Expected: " + idClass + ", got " + event.getEntityId().getClass());
}
However, EntityIdentityInsertAction has this in it's constructor:
delayedEntityKey = isDelayed ? generateDelayedEntityKey() : null;
and method:
private synchronized EntityKey generateDelayedEntityKey() {
if ( !isDelayed ) {
throw new AssertionFailure( "cannot request delayed entity-key for non-delayed post-insert-id generation" );
}
return new EntityKey( new DelayedPostInsertIdentifier(), getPersister(), getSession().getEntityMode() );
}
In case an insert is tried outside of an existing transaction users may run into this problem (like I did).
I don't know what the best fix is. The easiest fix would be:
Index: /Users/eelcohillenius/Documents/workspace/hibernate3/src/org/hibernate/event/def/DefaultLoadEventListener.java
===================================================================
--- /Users/eelcohillenius/Documents/workspace/hibernate3/src/org/hibernate/event/def/DefaultLoadEventListener.java (revision 11098)
+++ /Users/eelcohillenius/Documents/workspace/hibernate3/src/org/hibernate/event/def/DefaultLoadEventListener.java (working copy)
@@ -5,6 +5,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.NonUniqueObjectException;
@@ -10,7 +11,7 @@
import org.hibernate.NonUniqueObjectException;
import org.hibernate.PersistentObjectException;
import org.hibernate.TypeMismatchException;
-import org.hibernate.EntityMode;
+import org.hibernate.action.DelayedPostInsertIdentifier;
import org.hibernate.cache.CacheConcurrencyStrategy;
import org.hibernate.cache.CacheKey;
import org.hibernate.cache.entry.CacheEntry;
@@ -82,7 +83,7 @@
}
else {
Class idClass = persister.getIdentifierType().getReturnedClass();
- if ( idClass != null && ! idClass.isInstance( event.getEntityId() ) ) {
+ if ( idClass != null && ! (idClass.isInstance( event.getEntityId() ) || event.getEntityId() instanceof DelayedPostInsertIdentifier )) {
throw new TypeMismatchException(
"Provided id of the wrong type. Expected: " + idClass + ", got " + event.getEntityId().getClass()
);
but that would look like a quick hack to me.
--
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, 7 months
[Hibernate-JIRA] Created: (HHH-2494) ClassCastException from Subquery with Criteria created via DetachedCriteria
by Christopher Pierce (JIRA)
ClassCastException from Subquery with Criteria created via DetachedCriteria
---------------------------------------------------------------------------
Key: HHH-2494
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2494
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.2
Environment: Hibernate 3.2.2, Informix 10
Reporter: Christopher Pierce
If I create a DetachedCriteria object, then call "createCriteria" to on it, then pass a Subquery to the new Criteria, I get this exception:
java.lang.ClassCastException: org.hibernate.impl.CriteriaImpl$Subcriteria cannot be cast to org.hibernate.impl.CriteriaImpl
at org.hibernate.criterion.SubqueryExpression.toSqlString(SubqueryExpression.java:43)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:334)
at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:82)
at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:67)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1550)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
example:
public class EntityOne {
private long entityOneID
private EntityTwo entityTwo
...
}
public class EntityTwo {
private long entityTwoID
private EntityThree entityThree
...
}
public class EntityThree {
private long entityThreeID;
private String name;
...
}
DetachedCriteria subselect = DetachedCriteria.forClass(EntityThree.class);
subselect.add(Restrictions.like("name","test",MatchMode.START)).setProjection(Projections.id());
DetachedCriteria mainselect = DetachedCriteria.forClass(EntityOne.class);
mainselect.createCriteria("entityTwo").add(Subquery.in("entityThree",subselect));
mainselect.getExecutableCriteria(session).list();
This results in the ClasCastException error.
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-2183) org.hibernate.LazyInitializationException: failed to lazily initialize a collection while using lazy set with key as property-ref in the mapping
by Artur Jonak (JIRA)
org.hibernate.LazyInitializationException: failed to lazily initialize a collection while using lazy set with key as property-ref in the mapping
------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-2183
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2183
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.1.3
Environment: Oracle 9i
Reporter: Artur Jonak
Priority: Blocker
Attachments: hibernate-testcase.zip
I have an entity which can have multiple titles located in a separate table. I mapped this as a set where key attribute references other property of the entity:
<set name="titles" table="TTitle" cascade="none" lazy="true" inverse="true" mutable="false">
<key column="ID" property-ref="parentId"/>
<!--key column="ID"/-->
<element type="string" column="title"/>
</set>
when I try to display this set I get an exception:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: test.lazysetinit.Record.titles, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
...
The entire mapping is as follows:
<class name="Record" table="TRecord" mutable="false">
<id name="id" type="long">
<column name="ID" sql-type="number" length="12" not-null="true" unique="true"/>
</id>
<set name="titles" table="TTitle" cascade="none" lazy="true" inverse="true" mutable="false">
<key column="ID" property-ref="parentId"/>
<!--key column="ID"/-->
<element type="string" column="title"/>
</set>
<join table="TRecordInfo" inverse="true" fetch="join" optional="false">
<key column="ID"/>
<property name="parentId" not-null="false" />
<property name="status" />
</join>
</class>
Attached the test case: test.lazysetinit.LazySetInitTest. DB schema is located in test/conf/lazysetinit/schema.sql
Regards,
Artur
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-2453) Inserting BIT to PostgreSQL table
by Imran M Yousuf (JIRA)
Inserting BIT to PostgreSQL table
---------------------------------
Key: HHH-2453
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2453
Project: Hibernate3
Type: Bug
Components: query-sql
Environment: Not sure about the hibernate version but will add it soon, downloaded last June. PostrgreSQL 8.2.3 on RedHat Fedora Core 1. Spring Framework.
Reporter: Imran M Yousuf
Attachments: CallUser.hbm.xml, hibernate_pgsql.properties
I created a Table which has a column active as Boolean in the entity and the HBM file specifies the type as boolean. When I use this configuration with MySQL it works fine, but when I use it with PostgreSQL I get an javax.sql.BatchUpdateException. so later I changed the HBM file 'active' column type to 'yes_no' and than it works fine. So I confirmed that the problem is due to the BIT(1) column.
So I next tried to manually insert into the column and it PgSQL tells that 1 needs to be casted. Please let me know if I can help in other ways, I will be most grateful to help.
Thank you,
Imran
--
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, 8 months