Jakarta Data bug in processor when implementing CrudRepository
Description
Activity
Gavin KingApril 19, 2024 at 8:09 PM
Nope, not yet.
Well, wait, actually, according to the commit lot, I did indeed implement some sort of “experimental” support for this.
@Stephane Epardaud what precisely is not working there?
Gavin KingApril 18, 2024 at 6:22 PM
Is Jakarta Data really supposed to be compatible with Hibernate Reactive?
Nope, not yet.
Stephane EpardaudApril 18, 2024 at 1:46 PM
PR at https://github.com/hibernate/hibernate-orm/pull/8199
As for the HR + JD support, this is too big for me.
Stephane EpardaudApril 18, 2024 at 1:16 PM
I think there’s more than this error. None of the implementations match, since they return Uni<PanacheBook>
when the supertype wants them to also be parameterised and return <S extends PanacheBook> PanacheBook
, so that can’t fly.
Is Jakarta Data really supposed to be compatible with Hibernate Reactive?
Stephane EpardaudApril 18, 2024 at 1:07 PM
I decided to add the missing files in the test folders for now, and I’ve been able to verify my fix for the ORM side.
But it doesn’t work for HR. Uni<Mutiny.StatelessSession>
is not selected as the default session, I have to manually add a getter method. When I do, I’m left with an invalid implementation of updatedAll
:
@Override
public Uni<List> updateAll(@Nonnull List entities) {
Where I’m given this error:
/home/stephane/src/java-eclipse/hibernate-orm/tooling/metamodel-generator/target/classes/processor-generated-test-classes/org/hibernate/processor/test/hrPanache/JakartaDataBookRepository_.java:32:
error: org.hibernate.processor.test.hrPanache.JakartaDataBookRepository_
is not abstract and does not override abstract method
<S>updateAll(java.util.List<S>) in jakarta.data.repository.CrudRepository
I’ll try to find why.
Given this entity:
@Entity public class JDPerson { @GeneratedValue @Id public Long id; public String name; public LocalDate birth; public Status status; // No need for accessors for stateless sessions }
And this repository:
@Repository public interface PersonRepository extends CrudRepository<JDPerson, Long>{ }
I’m getting errors in the generated repo, related to not finding the
id
field, and a missing method:ERROR: The type PersonRepository_ must implement the inherited abstract method BasicRepository<JDPerson,Long>.findById(Long) PersonRepository_.java /hibernate63/target/generated-sources/annotations/org/acme/jd line 26 Java Problem /** * Find {@link JDPerson} by {@link JDPerson#arg0 arg0}. * * @see org.acme.jd.PersonRepository#deleteById(Long) **/ @Override public void deleteById(Long arg0) { var _builder = session.getFactory().getCriteriaBuilder(); var _query = _builder.createCriteriaDelete(JDPerson.class); var _entity = _query.from(JDPerson.class); _query.where( arg0==null ? _entity.get(JDPerson_.arg0).isNull() : _builder.equal(_entity.get(JDPerson_.arg0), arg0) ); ... } /** * Find {@link JDPerson} by {@link JDPerson#arg0 arg0}. * * @see org.acme.jd.PersonRepository#findAll(PageRequest) **/ @Override public Page<JDPerson> findAll(PageRequest<JDPerson> arg0) { var _builder = session.getFactory().getCriteriaBuilder(); var _query = _builder.createQuery(JDPerson.class); var _entity = _query.from(JDPerson.class); _query.where( arg0==null ? _entity.get(JDPerson_.arg0).isNull() : _builder.equal(_entity.get(JDPerson_.arg0), arg0) ); ... }