[Hibernate-JIRA] Created: (HHH-2586) Hibernate Serializable classes do not declare serialVersionUID
by Manuel Dominguez Sarmiento (JIRA)
Hibernate Serializable classes do not declare serialVersionUID
--------------------------------------------------------------
Key: HHH-2586
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2586
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.3, 3.2.2, 3.2.1, 3.2.0.ga, 3.2.0.cr5, 3.2.0.cr4, 3.2.0.cr3, 3.2.0.cr2, 3.2.0 cr1, 3.1.3, 3.2.0.alpha2, 3.2.0.alpha1, 3.1.2, 3.1.1, 3.1, 3.1 rc3, 3.1 rc2, 3.1 rc 1, 3.1 beta 2, 3.1 beta 1, 3.0.5, 3.0.4, 3.0.3, 3.0.2, 3.0.1, 3.0 final, 3.0 rc 1, 3.0 beta 4, 3.0 beta 3, 3.0 beta 2, 3.0 beta 1, 3.0 alpha
Environment: Not specific to any database, platform or Hibernate version.
Reporter: Manuel Dominguez Sarmiento
None of the Serializable classes in Hibernate declare serialVersionUID (see http://www.hibernate.org/hib_docs/v3/api/serialized-form.html#org.hiberna...).
This is recommended practice for ALL classes that implement the Serializable interface (see Joshua Bloch's Effective Java - Item #54). Adding these fields is trivial and takes little effort, but is a great enhancement if you are serializing Hibernate classes.
For instance, we upgraded from Hibernate 3.2.2 to 3.2.3 in our production servers. We serialize process state (which sometimes includes references to Hibernate-managed entities) every 30 seconds or so and on shutdown, so in the event of failures or re-deployment, the processes can continue where they left off. We had a huge surprise when deserialization failed completely because AbstractPersistentCollection had slightly changed between the 3.2.2 and 3.2.3 releases, and this caused the automatically-generated default serialVersionUID to change, even though the changes in the serialized form are compatible as far as we can tell.
--
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-2477) lazy fetching ManyToOne produces inproper proxies when using single table inheritance strategy
by Daniel Nguyen (JIRA)
lazy fetching ManyToOne produces inproper proxies when using single table inheritance strategy
----------------------------------------------------------------------------------------------
Key: HHH-2477
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2477
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.1
Environment: hibernate 3.2.1-GA, postgresql 8.1
Reporter: Daniel Nguyen
Attachments: bug.zip
I have entity base class Vehicle and entity class Car which extends Vehicle (using single table inheritance strategy).
I also have entity class User which have single-ended @ManyToOne relation from User to Vehicle with lazy fetching.
Now there is a Car instance "c" and User instance "u" with relation to "c". Lazily fetching vehicle from "u" results with proxy object "o" which is instanceof Vehicle but not instanceof Car as expected. So it's impossible cast "o" to Car or at least read any of Car's property from "o".
This is serious problem when inheritance is extensively used because inproper proxy object remains in cache. To walkaround I'd have to resign with lazy fetching (much performance loss) or manually replace proxy object in cache.
testing code:
SessionFactory sf = null;
Session s = null;
Transaction tx = null;
try
{
sf = cfg.buildSessionFactory();
s = sf.openSession();
tx = s.beginTransaction();
//create car
Car car = new Car();
car.setIdVehicle(1);
car.setAge(5);
s.save(car);
//create user of car
User user = new User();
user.setIdUser(1);
user.setVehicle(car);
s.save(user);
//make sure it is actually added
s.flush();
// test 1 - works ok, because we loaded vehicle before user
s.clear(); //clear cache
Vehicle vv = (Vehicle)s.get(Vehicle.class, 1);
User uu = (User)s.get(User.class, 1);
//we know that user vehicle is actually a Car
Car cc = (Car)uu.getVehicle();
// test 2 - fails, when using lazy fetching
s.clear(); //clear cache
User u = (User)s.get(User.class, 1);
Vehicle v = u.getVehicle();
//we know that user vehicle is actually a Car
//so we cast to Car but ClassCastException is raised!!!
Car c = (Car)v;
//let's check what's actual class of v
System.out.println(v.getClass().getName());
System.out.println(v.getClass().getSuperclass().getName());
//result:
// test.hibernate.Vehicle$$EnhancerByCGLIB$$12ce1883
// test.hibernate.Vehicle
//but I expected:
// test.hibernate.Car$$EnhancerByCGLIB$$xxxxx
// test.hibernate.Car
}
finally
{
if (tx!=null)
tx.rollback();
if (s!=null)
s.close();
if (sf!=null)
sf.close();
}
--
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, 4 months
[Hibernate-JIRA] Created: (HHH-2442) ClassCastException loading from second level cache
by Marcio Moraes (JIRA)
ClassCastException loading from second level cache
--------------------------------------------------
Key: HHH-2442
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2442
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.1, 3.2.2, 3.2.0.ga
Environment: Linux 2.6.15-27-686 #1 SMP PREEMPT Fri Dec 8 18:00:07 UTC 2006 i686 GNU/Linux
Reporter: Marcio Moraes
Priority: Blocker
I'm getting a error when using hibernate 3.2.2.ga with cache (JBoss-Cache) cluster.
When hibernate get a entity from second level cache it confuses the arrays of values against array of types.
So in some situations i got ClassCastException ...
Looking up CacheEntry code at assemble method i saw:
private static Object[] assemble(
final Serializable[] values,
final Object result,
final Serializable id,
final EntityPersister persister,
final Interceptor interceptor,
final EventSource session)
throws HibernateException {
//assembled state gets put in a new array (we read from cache by value!)
Object[] assembledProps = TypeFactory.assemble(
values,
persister.getPropertyTypes(),
session, result
);
The issue is values (Serializeble[]) is in wrong order compared with persister.getPropertyTypes() (Type[]).
If only one cache instance is running it doesnt occurs ...
I am using Linux.
Att,
Márcio Moraes
--
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, 4 months