jakartaee / jakartaee/persistence

TupleTransformer

Open
#78 5 comments 2 reactions 0 assignees View on GitHub
Priority: Major Type: New Feature
Dominant language
Java
Stars
267
Forks
78
Avg merge
1d 6h
Merged PRs (30d)
13

Description

The constructor syntax in JPQL is limited by the fact, that the class must be visible to the classloader of the persistence provider. Also one might want to apply a custom transformation strategy based on metadata that does not use constructors but factories, builders or setters. To overcome these limitations I propose the addition of a TupleTransformer interface which can be implemented by a user to provide custom strategies.

```
**TupleTransformer.java**public interface TupleTransformer {
List transform(List tuples);
X transform(Tuple tuple);
}
```

and an addition to Query and TypedQuery:

```
**Query.java**public interface Query {
// other methods
Query setTupleTransformer(TupleTransformer tupleTransformer);
}
```
```
**TypedQuery.java**public interface TypedQuery extends Query {
// other methods
TypedQuery setTupleTransformer(TupleTransformer tupleTransformer);
}
```

For reference see the ResultTransformer of Hibernate: [http://docs.jboss.org/hibernate/orm/4.3/javadocs/org/hibernate/transform/ResultTransformer.html](http://docs.jboss.org/hibernate/orm/4.3/javadocs/org/hibernate/transform/ResultTransformer.html)

Contributor guide

Open the contributing guide

Research direction

Start with the proposed TupleTransformer interface and the setTupleTransformer signatures in Query and TypedQuery. Compare the requested API with Hibernate's referenced ResultTransformer, then clarify the transformation behavior and integration points; done means the persistence API supports the agreed custom tuple-transformation strategy.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.