Skip to content

Comments

tuples and aliases#889

Open
gavinking wants to merge 9 commits intojakartaee:mainfrom
gavinking:#888
Open

tuples and aliases#889
gavinking wants to merge 9 commits intojakartaee:mainfrom
gavinking:#888

Conversation

@gavinking
Copy link
Member

A rough sketch of a possible way to deal with #888.

cc @sebersole

@gavinking gavinking added the candidate-for-4 Good candidate for JPA 4 label Jan 8, 2026
@sebersole
Copy link
Contributor

For certain Hibernate features, it would be nice to define a proper alias across all of the TupleElement impls.

E.g. ColumnMapping currently just uses the column-name as the alias.

Consider a Hibernate feature leveraging alias with with constructor result mappings - we allow users to map these in a way such that the aliases can be used to define bean property names for use in cases where the constructed class does not have an appropriate constructor. Roughly -

class DropDownItem {
    private Integer key;
    private String text;

    // getters/setters...
}

var key = column("key", "id", Integer.class);
var text = column("text", "name", String.class);
var dto = constructor(DropDownItem.class, key, text);

Of course, this might be kind of moot depending on the decision for #887

@gavinking
Copy link
Member Author

@sebersole Ok, fine, I can pull withAlias() up. Gimme 3 mins.

@gavinking
Copy link
Member Author

@sebersole There, done, is that what you mean?

@gavinking
Copy link
Member Author

Mmmmm @sebersole should we be targeting this one for M1?

@sebersole
Copy link
Contributor

Its not critical for M1 imo.

@gavinking
Copy link
Member Author

Its not critical for M1 imo.

OK then, not for M1.

@gavinking
Copy link
Member Author

OK, I believe I have now cleared up the ambiguity raised in #888, along with another ambiguity in the spec with respect to what types are allowed for @ColumnResult.

I've also added support for explicit aliases in programmatic result mappings, which AFAIU we all agree is useful.

Therefore I think this one is ready to go.

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

Labels

candidate-for-4 Good candidate for JPA 4 PRIORITY

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clarify behavior of EMF#getResultSetMappings when passed Object[] or Tuple

2 participants