Skip to content

@DbArray List<Integer> raises BeanNotEnhancedException #3888

Description

@PromanSEW

Javadoc for @DbArray says:

// Store as ARRAY of UUID on Postgres
@DbArray
List<UUID> uids = new ArrayList<>();

// Store as ARRAY on Postgres
@DbArray
List<String> phoneNumbers = new ArrayList<>();

// Store as ARRAY of INTEGER on Postgres
@DbArray
List<Long> someLongs = new ArrayList<>();

But if use this:

@DbArray
@Column(nullable = false)
public List<Integer> progress = new ArrayList<>();

I got BeanNotEnhancedException
If I change to this:

@DbJsonB
@Column(nullable = false)
public JsonNode progress;

Class compiles succesfully.
Why Javadoc behaviour is not working?

Ebean version: 17.1.0
I use enhancing by ebean-agent in Play Framework, and don't have querybean-generator in classpath

Activity

  1. rbygrave commented on Sep 21, 2026

    @rbygrave
    Member

    I got BeanNotEnhancedException

    You are not telling us what version of ebean you are using and what version and type of enhancement (maven, gradle, what version) and if there are any enhancement errors / warnings being reported during the enhancement.

    To be clear, there is some specific treatment for @DbArray as to it being nullable or not that changes the enhancement. That is, a non-nullable @DbArray will have pre-getter behaviour to automatically initialise the collection if it is null. So the @Column(nullable = false) is significant for @DbArray.

    This is because DbArray uses collections ... and generally it is nice to never deal with null for collection types (unless we explicitly expect null by making the mapping nullable).

    @DbJsonB ...

    It isn't a @DbArray and doesn't get the same treatment in terms of enhancement.

  2. PromanSEW commented on Sep 21, 2026

    @PromanSEW
    ContributorAuthor

    @rbygrave I added information to the end of issue immediately after creating. The main problem that Javadoc is lying that it working, changing field type was only for checking exception was gone or not

  3. PromanSEW commented on Sep 21, 2026

    @PromanSEW
    ContributorAuthor

    Removing @Column(nullable = false) fixed the problem, but SQL field is integer[], not integer[] not null
    EDIT: @Basic(optional = false) works fine

  4. rbygrave commented on Sep 21, 2026

    @rbygrave
    Member

    Removing @column(nullable = false) fixed the problem, but SQL field is integer[], not integer[] not null
    EDIT: @basic(optional = false) works fine

    Ok, this might be clear to me now although the "BeanNotEnhancedException" isn't clear.

    @basic(optional = false) works fine

    To be clear, it is really useful to be really obvious. I think you are saying that:

    This works (and now the column is not null which is what is desired)

    @DbArray
    @Basic(optional = false)
    public List<Integer> progress = new ArrayList<>();

    The following does NOT work? (which somehow shows up as BeanNotEnhancedException??)

    @DbArray
    @Column(nullable = false)
    public List<Integer> progress = new ArrayList<>();

    Also note that @DbArray(nullable=false) is also an option.

    @DbArray(nullable = false)
    public List<Integer> progress = new ArrayList<>();

    So assuming that is correct, what still is not clear is what "Does not work" actually means, as in a BeanNotEnhancedException is probably suggesting there is some other error reported during enhancement (but maybe that isn't exposed via the play enhancement?). Hmm, I might see if I can reproduce.

    Edit: Oh but for ebean we don't support the public fields (unless expert mode) ... so kinda suggests play might also be doing enhancement and so I do wonder if that is an issue (mixed play and ebean enhancement for this case).

  5. PromanSEW commented on Sep 21, 2026

    @PromanSEW
    ContributorAuthor

    @rbygrave You are right.
    This is working:

    @DbArray
    @Basic(optional = false)
    public List<Integer> progress = new ArrayList<>();
    @DbArray
    @Column(nullable = false)
    public List<Integer> progress = new ArrayList<>();

    Throws BeanNotEnhancedException.
    @DbArray(nullable = false) - also throws BeanNotEnhancedException.

  6. added a commit that references this issue on Sep 22, 2026
  7. rbygrave commented on Sep 22, 2026

    @rbygrave
    Member

    I was not able to reproduce this issue via - https://github.com/ebean-orm/ebean/pull/3889/changes

    Is there something else interesting around the constructor or class initialisation? Or is this Play specific perhaps? Ultimately we need a reproducing test case for this.

  8. PromanSEW commented on Sep 22, 2026

    @PromanSEW
    ContributorAuthor

    Cannot reproduce anymore, seems like build or code cache artifact, not bug in @DbArray
    Sorry

  9. rbygrave commented on Sep 22, 2026

    @rbygrave
    Member

    All good. Thanks for the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions