尝试更新时java.lang.AbstractMethodError

时间:2015-11-10 17:53:33

标签: java entity-framework hibernate jpa

我在尝试通过Hibernate / JPA更新数据库时收到以下异常:

Caused by: java.lang.AbstractMethodError: Method com/mchange/v2/c3p0/impl/NewProxyPreparedStatement.setCharacterStream(ILjava/io/Reader;J)V is abstract
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setCharacterStream(NewProxyPreparedStatement.java)
at org.hibernate.type.descriptor.sql.ClobTypeDescriptor$4$1.doBind(ClobTypeDescriptor.java:114)
at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:93)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:280)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:275)
at org.hibernate.type.AbstractSingleColumnStandardBasicType.nullSafeSet(AbstractSingleColumnStandardBasicType.java:57)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2786)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3191)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:3126)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3456)
at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:140)

当我尝试更新Derby DB(TIMESTAMP类型

)中的列时抛出

实体

@Entity
public class Tournament implements Serializable {
....
....
 @Column(name = "StartingTime", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Calendar startingTime = Calendar.getInstance();

通过代码执行更新通话:

public void setNewTournamentStartDate (short incrementHours, long tournamentId){
    EntityManager entityManager = entityManagerFactory.createEntityManager();
    Calendar startingDate = Calendar.getInstance();
       startingDate.add(Calendar.HOUR_OF_DAY, incrementHours);
       Query query = entityManager.createQuery("UPDATE Tournament t SET t.startingTime = :startingtime WHERE t.id = :tId");

       query.setParameter("startingtime", startingDate);
       query.setParameter("tId", tournamentId);
       query.executeUpdate();
       entityManager.getTransaction().commit();
    } catch (Exception e) {
        logger.debug("Exception caught ", e);
    }finally {
        entityManager.close();
    } 
}

我尝试在实体中使用Date类型或sql.Timestamp类型,但在更新时仍然会得到相同的异常。由于它是托管实体,我也试过检索它并且不使用SQL但只是使用setter来启动,但得到相同的错误。使用最新的实体管理器依赖关系更新的pom仍然相同。将检查Criteria API是否会产生不同的结果,但是这种感觉我在这里错误的方向和用完了。

0 个答案:

没有答案