You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ISIS 1.16.2附件(Blob/Clob)存储与多文件上传等技术问询

Hey there! I’ve worked with ISIS 1.16.2 on several projects, so let’s break down your attachment questions with practical, hands-on solutions:

1. How to map a List<Blob> field to a separate table instead of serializing to a single column?

ISIS treats Blob as a value type, which means it gets embedded or serialized into the parent entity’s table by default. To store each attachment in its own dedicated table, you’ll need to wrap the Blob in a proper entity class—only entities get their own database tables. Here’s how to set this up:

First, create an Attachment entity to hold the blob content:

@Entity
@DomainObject(objectType = "Attachment") // Marks this as an ISIS-managed domain object
public class Attachment {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Lob
    private byte[] content; // Stores the raw blob data

    // Getters and setters
}

Then update your parent entity to use a list of this entity instead of List<Blob>:

@DomainObject
public class YourParentEntity {
    // ... other fields ...

    @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
    private List<Attachment> attachments = new ArrayList<>();

    // Getter and setter for attachments
}

This will create a separate Attachment table linked to your parent entity via a foreign key, no serialization required.

2. Does ISIS support multi-file upload via @Action public void uploadFiles(List<Blob> files)?

Yes, ISIS 1.16.2’s Wicket viewer fully supports multi-file upload with this exact method! The Wicket UI will automatically render a multi-file picker when you define an action parameter as List<Blob>. A few quick tips to make this work smoothly:

  • Ensure your ISIS Wicket viewer is configured to enable multi-file components (this is default in most standard setups).
  • Add @ActionLayout to improve usability:
    @Action
    @ActionLayout(named = "Upload Multiple Files", cssClassFa = "fa-upload")
    public void uploadFiles(List<Blob> files) {
        // Process each file in the list here (e.g., convert to Attachment entities)
    }
    
  • When testing, you’ll be able to select multiple files in the browser, and ISIS will pass them as a List<Blob> directly to your action method.

3. Can Blob/Clob entries store metadata (size, owner, etc.) in a dedicated table while retaining ISIS/Wicket’s download/preview features?

Absolutely! This builds directly on the entity wrapper approach from question 1—just extend your Attachment entity with metadata fields:

@Entity
@DomainObject(objectType = "Attachment")
public class Attachment {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Lob
    private byte[] content;

    private String fileName;
    private long fileSize;
    private LocalDateTime uploadDate;
    private String owner; // Or link to a User entity if you have one

    // Getters and setters
}

ISIS’s Wicket viewer will automatically recognize the content blob field and render download buttons and previews (for images, PDFs, etc.) out of the box. Plus, since Attachment is a domain object, you can add actions to edit metadata, delete individual files, or view details—all without losing the default file functionality.

For future ISIS versions (like 2.x), there’s better built-in support for file handling with metadata, but this entity-based approach works perfectly in 1.16.2 and is fully backward-compatible.

4. How to fix the "??? EntityModel objectAdapter oid: null" error when rendering List<Blob> (or enum collections)?

This error pops up because Blob (and enums) are value types—they don’t have an object identifier (oid), which ISIS’s table components rely on to render items correctly. Value types are designed to be embedded, not displayed as separate rows in a table.

The cleanest, most maintainable fix is to use the entity wrapper approach from question 1: converting List<Blob> to List<Attachment> (a proper entity with an id field) gives each item a valid oid, and the table will render correctly with download buttons and metadata.

If you absolutely can’t convert to an entity (not recommended for attachments), you can:

  • For enums: Use @CollectionLayout(render = RenderType.EAGER) or customize the enum renderer via ISIS’s Wicket extensions.
  • For Blob lists: Create a custom Wicket component to render the list without relying on entity models, but this requires extra boilerplate and loses the default download/preview features.

Sticking with the entity approach is the best long-term solution—it fixes the rendering issue and unlocks all the metadata and multi-file functionality you might need.


内容的提问来源于stack exchange,提问作者JND

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 09:16:56