Skip to content

Conversation

@sebersole
Copy link
Member

@sebersole sebersole commented Nov 19, 2025

HHH-16383 - NaturalIdClass


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.


https://hibernate.atlassian.net/browse/HHH-16383

@sebersole
Copy link
Member Author

Remaining work mostly comess down to implementing branch in CompoundNaturalIdMapping#normalizeInput.

See

  • org.hibernate.orm.test.annotations.naturalid.idclass.SimpleNaturalIdClassTests#findByClassSmokeTest
  • org.hibernate.orm.test.annotations.naturalid.idclass.SimpleNaturalIdClassTests#findMultipleByClassSmokeTest

/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public NaturalIdClassAnnotation(ModelsContext modelContext) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'modelContext' is never used.
/**
* Used in creating annotation instances from JDK variant
*/
public NaturalIdClassAnnotation(NaturalIdClass annotation, ModelsContext modelContext) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'modelContext' is never used.
/**
* Used in creating annotation instances from Jandex variant
*/
public NaturalIdClassAnnotation(Map<String, Object> attributeValues, ModelsContext modelContext) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'modelContext' is never used.
@sebersole sebersole marked this pull request as ready for review November 21, 2025 17:51
@sebersole
Copy link
Member Author

A few things I still want to clean up (so please don't merge it), but this is mostly ready for review.

if ( factoryHint instanceof Integer number ) {
return Timeout.milliseconds( number );
}
return Timeout.milliseconds( Integer.parseInt( factoryHint.toString() ) );

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException Note

Potential uncaught 'java.lang.NumberFormatException'.
}
AccountId other = (AccountId) obj;
if (other != null && id != other.id)
if ( other != null && id != other.id ) {

Check warning

Code scanning / CodeQL

Useless null check Warning test

This check is useless.
other
cannot be null at this check, since it is guarded by
... == ...
.
Comment on lines +69 to +73
var book = entityManager.find( Book.class,
"978-9730228236",
KeyType.NATURAL,
LockMode.PESSIMISTIC_WRITE,
Timeout.seconds( 1 ) );

Check notice

Code scanning / CodeQL

Unread local variable Note test

Variable 'Book book' is never read.
Comment on lines +74 to +78
var books = entityManager.unwrap( Session.class ).findMultiple( Book.class,
List.of("978-9730228236"),
KeyType.NATURAL,
LockMode.PESSIMISTIC_WRITE,
Timeout.seconds( 1 ) );

Check notice

Code scanning / CodeQL

Unread local variable Note test

Variable 'List books' is never read.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants