简体   繁体   English

Hibernate 4.3.0 Final和Spring 4.1

[英]Hibernate 4.3.0 final and spring 4.1

Caused by: org.hibernate.type.SerializationException: could not deserialize
    at org.hibernate.internal.util.SerializationHelper.doDeserialize(SerializationHelper.java:262)
    at org.hibernate.internal.util.SerializationHelper.deserialize(SerializationHelper.java:306)
    at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.fromBytes(SerializableTypeDescriptor.java:155)
    at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:130)
    at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:44)
    at org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor$2.doExtract(VarbinaryTypeDescriptor.java:71)
    at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
    at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:263)
    at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:259)
    at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:249)
    at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:334)
    at org.hibernate.loader.Loader.extractKeysFromResultSet(Loader.java:784)
    at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:720)
    at org.hibernate.loader.Loader.processResultSet(Loader.java:952)
    at org.hibernate.loader.Loader.doQuery(Loader.java:920)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354)
    at org.hibernate.loader.Loader.doList(Loader.java:2551)
    at org.hibernate.loader.Loader.doList(Loader.java:2537)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2367)
    at org.hibernate.loader.Loader.list(Loader.java:2362)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:496)
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:387)
    at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:229)
    at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1260)
    at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103)
    at org.springframework.orm.hibernate4.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:875)
    at org.springframework.orm.hibernate4.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:864)
    at org.springframework.orm.hibernate4.HibernateTemplate.doExecute(HibernateTemplate.java:340)
    ... 59 more
Caused by: java.io.EOFException
    at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2325)
    at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2794)
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:801)
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:299)
    at org.hibernate.internal.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:328)
    at org.hibernate.internal.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:318)
    at org.hibernate.internal.util.SerializationHelper.doDeserialize(SerializationHelper.java:237)
    ... 86 more

Geting the above exception. 获取上述异常。

Following is class. 以下是课程。

@Entity
@Table(name = "USERS")
public class User implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "USER_ID", nullable = false)
    private Number userId;

    @Column(name = "USER_NAME", nullable = true)
    private String userName;

    @ManyToOne
    @JoinColumn(name="CLIENT_ID", unique=false, nullable=true, insertable=true, updatable=true)
    private Client client;

    @Column(name = "PASSWORD", nullable = true)
    private String password;

    @Column(name = "PASSWORD_CREATION_DATE", nullable = false)
    private Timestamp passwordCreationDate;

    @Column(name = "SALT", nullable = true)
    private String salt;

    @Column(name = "ADDRESS_ID", nullable = false)
    private Number addressId;

    @Column(name = "FIRST_NAME", nullable = true)
    private String firstName;

    @Column(name = "LAST_NAME", nullable = true)
    private String lastName;

    @Column(name = "EMAIL" , nullable = true)
    private String email;

    @Column(name = "IS_MADE_UP_USER_NAME"  , nullable = true)
    private boolean isMadeUpUserName;

    @Column(name = "CELL_PHONE" , nullable = true)
    private Number cellPhone;

    @Column(name = "LAST4SSN"  , nullable = true)
    private String last4SSN;

    @Column(name = "LOCKED" , nullable = false)
    private boolean locked;

    @Column(name = "FAILED_LOGIN_COUNT" , nullable = true)
    private Integer failedLoginCount;

    @Column(name = "DATE_CREATED" , nullable = false)
    private Timestamp dateCreated;

    @Column(name = "DATE_MODIFIED" , nullable = true)
    private Timestamp dateModified;

    @Column(name = "CREATED_BY_ID" , nullable = true)
    private Number createdBy;

    @Column(name = "MODIFIED_BY_ID" , nullable = true)
    private Number modifiedBy;

    @Column(name = "TIME_ZONE" , nullable = true)
    private String timeZone;

    @Column(name = "LANGUAGE"  , nullable = true)
    private String language;

    @Column(name = "USER_ENTERED_TEL"  , nullable = true)
    private Number userEnteredTel;

    @Column(name = "DO_NOT_NOTIFY"  , nullable = true)
    private boolean doNotNotify;
    enter code here
    @Column(name = "DISABLED"  , nullable = true)
    private boolean disabled;

    @Column(name = "TERMS_CONFIRMED" , nullable = true)
    private boolean termsConfirmed;

I don't know were am i wrong,please help me to solve the above. 我不知道我错了,请帮助我解决以上问题。 getting deserialization exception.Due to this desialixation its causing eof exception too.the error in the above class. 获取反序列化异常。由于这种反序列化,它也导致eof异常。上述类中的错误。

following is table structure 以下是表结构

 `user_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_name` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
  `Password` varchar(256) DEFAULT NULL,
  `password_creation_date` datetime DEFAULT NULL,
  `salt` varchar(50) DEFAULT NULL,
  `address_id` decimal(10,0) NOT NULL,
  `client_id` int(11) DEFAULT NULL,
  `first_name` varchar(100) DEFAULT NULL,
  `last_name` varchar(100) DEFAULT NULL,
  `email` varchar(100) DEFAULT NULL,
  `is_made_up_user_name` tinyint(1) DEFAULT '0',
  `cell_phone` decimal(10,0) DEFAULT NULL,
  `dob` varchar(45) DEFAULT NULL,
  `last4ssn` varchar(45) DEFAULT NULL,
  `locked` tinyint(1) NOT NULL,
  `disabled` tinyint(1) DEFAULT '0',
  `failed_login_count` int(11) DEFAULT NULL,
  `date_created` date NOT NULL,
  `date_modified` date DEFAULT NULL,
  `created_by_id` decimal(10,0) DEFAULT NULL,
  `modified_by_id` decimal(10,0) DEFAULT NULL,
  `time_zone` varchar(256) DEFAULT NULL,
  `language` varchar(256) DEFAULT NULL,
  `user_entered_tel` decimal(10,0) DEFAULT NULL,
  `do_not_notify` tinyint(1) DEFAULT '1',
  `terms_confirmed` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`user_id`),
  UNIQUE KEY `user_name` (`user_name`),
  KEY `client_id` (`client_id`),
  CONSTRAINT `USERS_ibfk_1` FOREIGN KEY (`client_id`)
                            REFERENCES `client` (`client_id`)
  1. write a (j)unit test for it, eg just loading this class via some (maybe self-injected EntityManager ) 为此编写一个(j)单元测试 ,例如,仅通过某些方法(可能是自我注入的EntityManager )加载此类。
  2. comment out critical parts that could lead to this, eg any entity reference: 注释掉可能导致这种情况的关键部分 ,例如任何实体参考:

     //@ManyToOne //@JoinColumn(name="CLIENT_ID", unique=false, nullable=true, insertable=true, // updatable=true) //private Client client; 
    • and dependent methods inside 里面的依赖方法
  3. run the simple JPA bean, which should likely be fine 运行简单的JPA bean,这应该没问题
  4. now check your 'Client' class, that it does not reference any other entity and comment in the above with the most basic settings , eg 现在检查您的“客户端”类,以确保它没有引用任何其他实体,在上面使用最基本的设置进行注释 ,例如

     @ManyToOne @JoinColumn(name="CLIENT_ID") private Client client; 
  5. now you should get closer to the declarations that cause the trouble 现在您应该更接近引起麻烦的声明

You should also enable hibernate sql logging and parameter logging to see whats going on underneath. 应该启用休眠SQL日志记录和参数日志记录,以查看其下发生了什么。

I got a the same error on a similar setup and it was caused by a wrong modeling/fiddling with the annotations and relationships where this source helped me out: http://levelup.lishman.com/hibernate/associations/many-to-one.php 在类似的设置上遇到了相同的错误 ,这是由错误的建模/摆弄注释和关系引起的 ,此来源帮助我: http : //levelup.lishman.com/hibernate/associations/many-to-一个.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring 4.3.0.RELEASE + Hibernate 5.2.0.Final - mysql上的GeneratedValue - Spring 4.3.0.RELEASE + Hibernate 5.2.0.Final - GeneratedValue on mysql Spring 4.3.0.RELEASE + Hibernate 5.2.0.Final + JPA Repository - Spring 4.3.0.RELEASE + Hibernate 5.2.0.Final + JPA Repository Hibernate 4.3.0.Final和Spring Data JPA 1.4.3.RELEASE - Hibernate 4.3.0.Final & Spring Data JPA 1.4.3.RELEASE Spring 4.3.0.RELEASE + Hibernate 5.2.0.Final -Error .. with root cause org.hibernate.PersistentObjectException - Spring 4.3.0.RELEASE + Hibernate 5.2.0.Final -Error.. with root cause org.hibernate.PersistentObjectException Spring 4.3.0.RELEASE + Hibernate 5.2.0.Final-Spring安全错误 - Spring 4.3.0.RELEASE + Hibernate 5.2.0.Final - Spring Security Error Hibernate 4.3.0.Final获取会话 - Hibernate 4.3.0.Final get session Spring 4.3.0.RELEASE + Hibernate 5.2.0.Final-无法获得当前线程的事务同步会话 - Spring 4.3.0.RELEASE + Hibernate 5.2.0.Final - Could not obtain transaction-synchronized Session for current thread 使用Hibernate-entitymanager 4.3.0.Final in Play 2.2.1项目? - Using hibernate-entitymanager 4.3.0.Final in Play 2.2.1 project? 从 Eclipse Luna 卸载 JBoss Tools 4.3.0 Final (Hibernate) - Uninstall JBoss Tools 4.3.0 Final (Hibernate) from Eclipse Luna 使用Maven的Spring 3.1和Hibernate 4.1 - Spring 3.1 and Hibernate 4.1 with Maven
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM