[Hibernate-JIRA] Created: (HHH-5550) Hibernate.createBlob() fails when used in current_session_context_class=thread mode
by Zemian Deng (JIRA)
Hibernate.createBlob() fails when used in current_session_context_class=thread mode
-----------------------------------------------------------------------------------
Key: HHH-5550
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5550
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.5.5
Reporter: Zemian Deng
See https://forum.hibernate.org/viewtopic.php?f=1&t=1004366
Here is a unit test failed case:
{code:java}
package deng.hibernate.examples.blob;
import org.hibernate.*;
import org.hibernate.cfg.*;
import org.junit.Test;
public class HibernateCreateBlobFailedCase {
@Test
public void createBlob() {
Configuration cfg = new Configuration();
SessionFactory sessionFactory = cfg.configure().buildSessionFactory();
Session session = sessionFactory.getCurrentSession();
Transaction tx = null;
try {
tx = session.beginTransaction();
byte[] blobBytes = new byte[]{};
Hibernate.createBlob(blobBytes, session);
} catch (Throwable e) {
tx.rollback();
throw new RuntimeException(e);
} finally {
sessionFactory.close();
}
}
}
{code}
Set hibernate.cfg.xml with thread session context
{code:xml}
...
<property name="current_session_context_class">thread</property>
...
{code}
You will get this stack trace
{noformat}
java.lang.RuntimeException: java.lang.ClassCastException: $Proxy4 cannot be cast to org.hibernate.engine.jdbc.LobCreationContext
at deng.hibernate.examples.blob.HibernateCreateBlobFailedCase.createBlob(HibernateCreateBlobFailedCase.java:24)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
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.lang.ClassCastException: $Proxy4 cannot be cast to org.hibernate.engine.jdbc.LobCreationContext
at org.hibernate.Hibernate.getLobCreator(Hibernate.java:502)
at org.hibernate.Hibernate.getLobCreator(Hibernate.java:498)
at org.hibernate.Hibernate.createBlob(Hibernate.java:494)
at deng.hibernate.examples.blob.HibernateCreateBlobFailedCase.createBlob(HibernateCreateBlobFailedCase.java:21)
... 22 more
{noformat}
As described in forum, this problem occurred because the session object we get using {{sessionFactory.getCurrentSession();}} is an wrapped ThreadLocalSessionContext instance that can not be cast into LobCreationContext. There is no easy way to unwrap and get the original session object, to pass to createBlob method.
--
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, 5 months
[Hibernate-JIRA] Created: (HHH-5430) Better Firebird support - temp tables, short column names
by Martin Černý (JIRA)
Better Firebird support - temp tables, short column names
---------------------------------------------------------
Key: HHH-5430
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5430
Project: Hibernate Core
Issue Type: Improvement
Components: core
Affects Versions: 3.5.3
Reporter: Martin Černý
Priority: Minor
Attachments: Firebird21Dialect.java, GenericLengthLimitedNamingStrategy.java, LengthLimitedComponentSafeNamingStrategy.java
Sorry for not posting in some more concise format or joining the development in an official way, however I hope it still helps.
In my quest to make Firebird work with my Hibernate/JPA project I have developed two helper classes that (especially the first one) might as well be incorporated in the Hibernate.
First I have subclassed FirebirdDialect to make use of temporary table support in Firebird 2.1 (this had blocked some of the JPA features)
Then I have subclassed NamingStrategy to create a generic strategy that forces all the database identifiers to conform to certain length. This is needed since Firebird does not work with column and table names longer than 30 chars. Although I am not certain, if this should be part of Hibernate.
The class I created are attached, their utility is up to the consideration of the community
--
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, 5 months
[Hibernate-JIRA] Created: (HHH-3230) getEntityName() throws org.hibernate.TransientObjectException: proxy was not associated with the session
by Howard M. Lewis Ship (JIRA)
getEntityName() throws org.hibernate.TransientObjectException: proxy was not associated with the session
--------------------------------------------------------------------------------------------------------
Key: HHH-3230
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3230
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.2
Environment: Mac OS X, JDK 1.5
Reporter: Howard M. Lewis Ship
I'm retrieving an entity that contains a OneToMany relationship.
The master entity is retrieved, within a transaction, via Session.get(Class,Serializable).
@Entity
public class MapUnitSurvey extends ActiveDO
{
@ManyToOne(fetch = FetchType.LAZY)
private VegetationType vegetationType;
}
@Entity
public class VegetationType extends AbstractEnum
{
}
ActiveDO and AbstractEnum are abstract base classes with @MappedSuperclass.
I retrieve the vegationType:
VegetationType type = survey.getVegetationType();
Then I need the type's entity name
String entityName = session.getEntityName(type);
This fails with the TransientObjectException.
Inspecting with the debugger, I see that type is a CGLIB-enhanced proxy, and that there's a fully initialized bean in the target field of the proxy. I'll attach a screenshot of some debugging data.
In summary; the entity was retrieved via a lazy fetch, appears the be correct, seems to be in the session and yet the exception occurs.
I've tried to resolve this by re-fetching the object from the session, and a few other tries, with no luck.
--
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, 5 months
[Hibernate-JIRA] Created: (HHH-3332) Hibernate duplicate then child entity's on merge
by Rodrigo de Assumpção (JIRA)
Hibernate duplicate then child entity's on merge
------------------------------------------------
Key: HHH-3332
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3332
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.6
Environment: JDK 1.6
Oracle 9i
Hibernate 3.2.6
Hibernate Annotations 3.3.1
Hibernate EntityManager 3.3.2
Standalone Running
Reporter: Rodrigo de Assumpção
Priority: Critical
The method merge from EntityManager causes a duplication of child entity's.
class Father:
@OneToMany(mappedBy = "father", cascade={CascadeType.ALL}, fetch=FetchType.LAZY)
private List<Child> childList;
class Child:
@ManyToOne @JoinColumn(name = "ID_FATHER")
private Father father;
class BugTest
EntityManagerFactory emf = Persistence.createEntityManagerFactory("JpaTestHB");
EntityManager em = emf.createEntityManager();
Father f = (Father) em.createQuery("SELECT f FROM Father f WHERE f.id = 1").getSingleResult();
Child c = new Child();
c.setFather(f);
f.getChildList().add(c);
em.getTransaction().begin();
em.merge(f);
em.getTransaction().commit();
The execution of BugTest Class causes tow insert's on table "child".
If you change the fetch mode to EAGER (into Father class) the problem not occurs.
I make the same test with Toplink, and it make a unique insert, normal.
--
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, 5 months
[Hibernate-JIRA] Created: (HHH-5359) Derived entity usecase fails when the association is bidirectional
by Hardy Ferentschik (JIRA)
Derived entity usecase fails when the association is bidirectional
------------------------------------------------------------------
Key: HHH-5359
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5359
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.5.3
Reporter: Hardy Ferentschik
Fix For: 3.6
See https://forum.hibernate.org/viewtopic.php?f=9&t=1005649
The exception is
{noformat}
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: org.hibernate.test.annotations.derivedidentities.bidirectional.Dependent.emp in org.hibernate.test.annotations.derivedidentities.bidirectional.Employee.dependents
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:655)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:619)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:66)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1221)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:383)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1377)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
at org.hibernate.test.annotations.TestCase.buildConfiguration(TestCase.java:114)
at org.hibernate.test.annotations.HibernateTestCase.setUp(HibernateTestCase.java:133)
at org.hibernate.test.annotations.HibernateTestCase.runBare(HibernateTestCase.java:80)
at com.intellij.junit3.JUnit3IdeaTestRunner.doRun(JUnit3IdeaTestRunner.java:108)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:64)
{noformat}
The mapping is as follows:
{code}
@Entity
public class Employee {
@Id
long empId;
String empName;
@OneToMany(mappedBy = "emp", fetch = FetchType.LAZY)
private Set<Dependent> dependents;
}
{code}
{code}
@Entity
//(a)IdClass(DependentId.class)
public class Dependent implements Serializable {
@Id
@ManyToOne
Employee emp;
String name;
}
{code}
It does not work with @IdClass either.
--
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, 5 months
[Hibernate-JIRA] Created: (HHH-5529) Bulk delete on Entity with @ElementCollection ignores the @CollectionTable
by Pascal Thivent (JIRA)
Bulk delete on Entity with @ElementCollection ignores the @CollectionTable
--------------------------------------------------------------------------
Key: HHH-5529
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5529
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.6.0.Beta4, 3.6.0.Beta3, 3.5.5, 3.6.0.Beta2, 3.6.0.Beta1, 3.5.4, 3.5.3, 3.5.2, 3.5.1, 3.5.0-Final, 3.5.0-CR-2, 3.5.0-CR-1, 3.5.0-Beta-4, 3.5.0-Beta-3, 3.5.0-Beta-2, 3.5.0.Beta-1
Environment: Hibernate 3.5.x, all database, all platforms.
Reporter: Pascal Thivent
Attachments: HHH-XXX.tar.gz
I have an entity with a collection of basic elements mapped with @ElementCollection:
{code}
@Entity
public class Foo {
@Id @GeneratedValue
private Long id;
@ElementCollection
@Column(name = "bar_column")
@CollectionTable(name = "Bar")
private Set<String> bars = new HashSet<String>();
public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
public Set<String> getBars() { return bars; }
public void setBars(Set<String> bars) { this.bars = bars; }
}
{code}
A bulk delete on this entity fails due to constraint violation on the collection table (Hibernate ignores the collection table).
I don't think that the following cascading restriction from the JPA 2.0 specification applies:
{quote}
h3. 4.10 Bulk Update and Delete Operations
...
A delete operation only applies to entities of the specified class and its subclasses. It does not cascade to related entities.
{quote}
In other words, Hibernate should handle the collection table as we have no way to bulk delete the basic elements from the collection table.
I have attached a test case allowing to reproduce the issue.
--
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, 5 months
[Hibernate-JIRA] Created: (HHH-5280) "java.lang.IllegalArgumentException: object is not an instance of declaring class" when persisting a object graph containing the same transient objetc twice.
by Benjamin Lerman (JIRA)
"java.lang.IllegalArgumentException: object is not an instance of declaring class" when persisting a object graph containing the same transient objetc twice.
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-5280
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5280
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.2
Environment: Hibernate 3.5.2
Db: All? (At least h2 and mysql)
Reporter: Benjamin Lerman
Priority: Critical
Attachments: hibernate-multi-parent.tgz, test.entity.TestCreate.txt
I attach a maven project showing the bug.
I have 3 classes, A, B, C with
C have a one-to-many unidirectional relation to B and A.
B have a one-to-many unidirectional relation to A.
Those relations are mapped by foreign keys.
The cascading properties for those relations are all save-update,persist
For each of those relations, the inverse cardinality is 1 (which means A must be associated with a B and a C, and B must be associated with a C).
I create an instance of C that I associate to an instance of B and an instance of A, and I associate the instance of B with the instance of A.
I then try to save C, and I get the attached exception.
For what I understood the problem is with the method StatefulPersistenceContext.getOwnerId: this method use a cache to retrieve the parent of the instance of A, but because A has 2 different parents (the instance of B and the instance of C), it does not retrieve the right one and try to call a method on the wrong entity.
--
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, 5 months