Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serializer for org.hibernate.proxy.HibernateProxy #104

Open
gMan1990 opened this issue Dec 26, 2018 · 3 comments
Open

serializer for org.hibernate.proxy.HibernateProxy #104

gMan1990 opened this issue Dec 26, 2018 · 3 comments

Comments

@gMan1990
Copy link

gMan1990 commented Dec 26, 2018

a Entity instance that select with hibernate from db, but it's a HibernateProxy

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import org.hibernate.annotations.DynamicUpdate;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Entity
@DynamicUpdate
public class DemoEntity {
  @Id
  private Long id;
  private Date createTime;
}

how serialization and deserialization the instance?

Caused by: java.io.NotSerializableException: org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184) ~[?:1.8.0_192]
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348) ~[?:1.8.0_192]
	at com.esotericsoftware.kryo.serializers.JavaSerializer.write(JavaSerializer.java:51) ~[kryo-4.0.2.jar:?]
	at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:575) ~[kryo-4.0.2.jar:?]
	at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:79) ~[kryo-4.0.2.jar:?]
	at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:508) ~[kryo-4.0.2.jar:?]
	at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:575) ~[kryo-4.0.2.jar:?]
	at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:79) ~[kryo-4.0.2.jar:?]
	at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:508) ~[kryo-4.0.2.jar:?]
	at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:651) ~[kryo-4.0.2.jar:?]
@magro
Copy link
Owner

magro commented Dec 26, 2018

Do you want to submit a PR?

@gMan1990
Copy link
Author

@magro not PR, a question, (updated at home just now, sorry!

@magro
Copy link
Owner

magro commented Dec 26, 2018

I'd suggest to check out how hibernate proxy implements Java serialization and then implement it for kryo. Alternatively you could have a look at hibernate proxy serialization of other serialization libs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants