简体   繁体   English

在与jboss捆绑在一起的liferay-6.1.2-ce-ga3中Blob数据更新失败

[英]Blob data updation failed in liferay-6.1.2-ce-ga3 bundled with jboss

I have a requirement of inserting and updating blob data in liferay portlet project.I am using liferay-6.1.2-ce-ga3 for development. 我需要在liferay portlet项目中插入和更新blob数据。我正在使用liferay-6.1.2-ce-ga3进行开发。 My service.xml has following blob field 我的service.xml具有以下blob字段

 <column name="applicationData" type="Blob" db-name="application_data" />

After service build I have successfully inserted the blob data using service builder generated classes. 服务构建之后,我已经使用服务构建器生成的类成功插入了Blob数据。

   myEntity.setApplicationData(blobdata);  
   myEntityLocalServiceUtil.addMyEntity(myEntity);

I tried to update blob data as follows 我尝试如下更新blob数据

  myEntity.setCachedModel(false);    
  myEntity.setApplicationData(blobdata);
  myEntityLocalServiceUtil.updateMyEntity(myEntity,false);

But everything except blob data is getting updated. 但是除了blob数据之外的所有东西都在更新。 When I checked the BatchSessionImpl source, I noticed that there is no method like session.saveOrUpdate(model) call in it's update method which normally does blob update by skipping session.merge(model) . 当我检查BatchSessionImpl源时,我注意到在它的update方法中没有像session.saveOrUpdate(model)那样的方法调用,该方法通常通过跳过session.merge(model)来进行 blob更新。

Below is the update method of BatchSessionImpl class 下面是BatchSessionImpl类的更新方法

public void update(Session session, BaseModel<?> model, boolean merge)
    throws ORMException {

    if (merge || model.isCachedModel()) {
        session.merge(model);
    }
    else {
        if (model.isNew()) {
            session.save(model);

            model.setNew(false);
        }
        else {
            session.merge(model);
        }
    }

    if (!isEnabled()) {
        session.flush();

        return;
    }

    if ((PropsValues.HIBERNATE_JDBC_BATCH_SIZE == 0) ||
        ((_counter.get() % PropsValues.HIBERNATE_JDBC_BATCH_SIZE) == 0)) {

        session.flush();
    }

    _counter.set(_counter.get() + 1);
}

In my case session.merge(model) in the else case is getting invoked. 在我的情况下,在其他情况下的session.merge(model)被调用。 Is there any thing specific with liferay-6.1.2-ce-ga3 bundled with jboss so that we can update blob data?. 与jboss捆绑在一起的liferay-6.1.2-ce-ga3有什么特别的东西,以便我们可以更新blob数据吗? Can someone suggest me some workarounds.? 有人可以建议我一些解决方法吗?

I have resolved the issue by creating an ext plugin. 我已经通过创建ext插件解决了该问题。 I made changes in ext-impl for BatchSessionImpl class for the update method as follows 我在ext-impl中更改了BatchSessionImpl类的更新方法,如下所示

public void update(Session session, BaseModel<?> model, boolean merge)
    throws ORMException {

    if (merge || model.isCachedModel()) {
        session.merge(model);
    }
    else {
        if (model.isNew()) {
            session.save(model);

            model.setNew(false);
        }
        else {
            session.saveOrUpdate(model);
        }
    }

    if (!isEnabled()) {
        session.flush();

        return;
    }

    if ((PropsValues.HIBERNATE_JDBC_BATCH_SIZE == 0) ||
        ((_counter.get() % PropsValues.HIBERNATE_JDBC_BATCH_SIZE) == 0)) {

        session.flush();
    }

    _counter.set(_counter.get() + 1);
}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM