-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
HHH-13604 Check APIs used after the SessionFactory has been created #3040
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
3e4d6ae
to
4fac35b
Compare
It seems that skipping all the cases when the @Sanne thanks for help you've provided so far, |
yes please! That's what we need. |
735fe57
to
688f250
Compare
Hi @Sanne, it seems that our investment has borne some fruits. In fact, activating the Byteman rules we can catch both some readings of annotations and some compations of new regular expressions after that the session factory has been created. As a follow up, I created: HHH-13669 The rules are not active, in order to keep the tests from failing. Meanwhile is it the case to merge this request and close the related issue? Thanks |
if ( this == o ) { | ||
return true; | ||
} | ||
Book book = (Book) o; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should check parameter's class before down casting
@Override | ||
public int hashCode() { | ||
return Objects.hash( id, isbn, title, author, copies ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that id field is not generated, it seems the above two methods should be based on it exclusively.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe using getter method is more appropriate for two reasons:
- be consistent with
equals()
method above - proxy friendly
/** | ||
* @author Fabio Massimo Ercoli | ||
*/ | ||
@TestForIssue(jiraKey = "HHH-13604") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal, but using space chars right after '(' and before ')' would be consistent with existing coding format
readClass = Class.forName( "org.hibernate.session.runtime.check.Book" ); | ||
} | ||
catch (ClassNotFoundException e) { | ||
throw new RuntimeException( e ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might well use throw new ExceptionInInitializerError( e );
|
||
doInHibernate( this::sessionFactory, session -> { | ||
Book loaded = session.load( Book.class, 1 ); | ||
assertEquals( book, loaded ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I understand your implementation of equals
for sake of testing purpose. We might well use Assert.assertTrue(EqualsBuilder.reflectionEquals(expected,actual));
to avoid providing a non-intuitive equals
overridden method.
I'm closing this pull request, I could reopen it if we need it. |
https://hibernate.atlassian.net/browse/HHH-13604
I had to comment some code, since regex pattern compile is still used at runtime.not anymore!At the very moment the rules are active only for
CheckForbiddenAPIAtRuntimeTest
run.In order to apply the rules to all tests, please remove or comment:
of
org.hibernate.testing.junit4.runtimecheck.BMRuntimeCheckCustomRunner
class.