glassfish icon indicating copy to clipboard operation
glassfish copied to clipboard

Jakarta Data IllegalArgumentException: An instance of a null PK has been incorrectly provided for this find operation

Open hantsy opened this issue 1 month ago • 4 comments

GlassFish Version (and build number)

8.0.0-M14

JDK version

21

OS

Windows 10 pro 64 bit

Database

No response

Problem Description

A simple Repository interface does not extend from the existing CrudRepository,


@Repository
public interface Blogger {


    @Query("""
            SELECT p.id, p.title FROM Post AS p
            WHERE p.title LIKE :title
            ORDER BY p.createdAt DESC
            """)
    Page<PostSummary> allPosts(@Param("title") String title, PageRequest page);

    @Find
    @OrderBy("createdAt")
    List<Post> byStatus(Status status, Order<Post> order, Limit limit);

    @Find
    Optional<Post> byId(UUID id);

    @Insert
    Post insert(Post post);

    @Update
    Post update(Post post);

    @Delete
    void delete(Post post);

    // see: https://hibernate.zulipchat.com/#narrow/stream/132096-hibernate-user/topic/Jakarta.20Data.20cascade.20does.20not.20work.20in.20custom.20deletion.20Query/near/441874793
    @Query("delete from Post")
    @Transactional
    long deleteAllPosts();

    @Insert
    Comment insert(Comment comment);
}

And running a simple test https://github.com/hantsy/jakartaee11-sandbox/blob/master/data/src/test/java/com/example/it/BloggerTest.java will got the exception.

Steps to reproduce

  1. Clone https://github.com/hantsy/jakartaee11-sandbox/blob/master/data
  2. Enter data folder, and run mvn clean verify -Parq-glassfish-managed -Dit.test=BloggerTest

Impact of Issue

No response

hantsy avatar Nov 14 '25 03:11 hantsy

Which is similar to https://github.com/eclipse-ee4j/glassfish/issues/25778, but use a different free-style repository interface.

hantsy avatar Nov 14 '25 04:11 hantsy

@arjantijms For this BloggerTest, I have removed the query result projection, still encountered the same errors.

hantsy avatar Nov 27 '25 02:11 hantsy

This should be fixed by https://github.com/eclipse-jnosql/jnosql-extensions/pull/165

Should be fixed when a new 1.1.12 version of JNoSQL is released and integrated to GlassFish.

OndroMih avatar Nov 27 '25 07:11 OndroMih

I have changed first query to use Jakarta Data 1.0 compatible simple query, the tests still fail to run on Glassfish v8.0.0-M15

hantsy avatar Dec 17 '25 13:12 hantsy

I built the GlassFish main branch with JNoSQL 1.1.12-SNAPSHOT and the test passes.

With JNoSQL 1.1.11 it fails, with this error:

IllegalArgumentException: An instance of a null PK has been incorrectly provided for this find operation.

It means that we'll need to wait for JNoSQL 1.1.12 with this fix https://github.com/eclipse-jnosql/jnosql-extensions/pull/165 and integrate it into GlassFish. Then the test will pass.

OndroMih avatar Dec 22 '25 19:12 OndroMih

Raised https://github.com/eclipse-ee4j/glassfish/issues/25851 to upgrade JNoSQL, which fixes this issue. Closing this issue now.

OndroMih avatar Dec 22 '25 19:12 OndroMih