-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[JPA] [do not apply] Raw intermediary infrastructure to get a JPA deployment work in Shamrock #5
Conversation
Thanks, I'll look soon. Did a blind build and got this: [INFO] shamrock-strict-example 1.0.0.Alpha1-SNAPSHOT ...... FAILURE [ 0.109 s] expected? |
@stuartwdouglas that's not the usual Maven error. A shamrok specific validation? |
@Override | ||
public void process(ArchiveContext archiveContext, ProcessorContext processorContext) throws Exception { | ||
// Hibernate specific reflective classes | ||
processorContext.addReflectiveClass(org.hibernate.jpa.HibernatePersistenceProvider.class.getName()); |
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.
nice approach!
Just FYI we no longer need org.hibernate.jpa.HibernatePersistenceProvider
, I actrually had to fully exclude it to get rid of the XML parser dependency.
But I get the idea, this is an example.
/** | ||
* @author Emmanuel Bernard [email protected] | ||
*/ | ||
public class JPADeploymentTemplate { |
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.
Ok I start to "get" it, very useful thanks.
Just keep in mind we'll need to record a far more complex structure; in order of priority:
- named containers: a separate JPADeployment for each PU
- pre-parsed XML and configurations (and upfront validation)
- entities will need to be pre-enhanced as needed
- Some explicit classes and types; e.g. resolve the
Dialect
already so that only one dialect (for each PU) is included. - validatorFactory -> inject by instance an option?
- cdiBeanManager -> inject by instance an option?
- output of custom StandardServiceInitiator (more instances?) (optional?)
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.
yep. To be fair, I think this template thing will go away and we will just boot your PersistenceProvider bypass as the solution.
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.
yet my "persistence bypass" will need to fetch such state from somewhere; and we'll need such a processor to define all reflection permissions.
In particular while we can hard code the "framework internal reflective needs", we'll need ad-hoc permissions generated on the user model so this angle will need to be used as well.
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.
yes the callback idea you had is how I am seeing it at the moment
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.
We should probably talk about this more, and get an idea about exactly what is needed from shamrock. It would be pretty easy to add the ability to serialise simple objects to the template, as long as they have getters and setters with a no arg constructor.
Looking at the current hibernate code it looks like all the parsing is done in static init, so it is pre-done for the native image, but when running in java mode it is still parsed at runtime.
@stuartwdouglas can you take that branch and look at it. There are things around the build process that I don't understand. First off, master work for me when I do This branch fails on the strict project claiming it cannot find the native image even though an old version of the image is there. The big difference is that I have added a new What is weird though is that it runs the tests before building the native image (I don't see logs running the native image). When I go in
That makes me think the first test does not clean after itself. Anyways, I'm a bit lost and any help would be appreciated @stuartwdouglas |
* | ||
* @author Emmanuel Bernard [email protected] | ||
*/ | ||
@RunWith(ShamrockTest.class) |
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.
This is running in JVM mode, so it does not really prove anything.
public class JPAReflectionInGraalTestCase { | ||
|
||
@Test | ||
public void testFieldAndGetterReflectionOnEntity() throws Exception { |
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.
This test is also run on the JVM (from the maven failsafe process).
If we want to be able to run unit tests like this in the native image then the GraalTest framework will need to somehow package up all the unit test code into a new test image. This should be possible, but I am not sure if it is worth worrying about for the Poc?
At the moment the graal based tests work via HTTP, so you send a HTTP request to the image and verify you get the correct result.
Make sure the test is run in the native image and called from a servlet endpoint
@Sanne you can try again, the tests should pass now. |
merged |
another set of updates based on PR comments
@Sanne FYI