Help

Per HHH-2412 and its design discussion I have been working on supporting JDBC4 in Hibernate. Initially I had planned on adding this in 3.6, but now leaning toward 3.5 Anyway, as outlined on the design wiki, I initially thought to add this support as separate modules. However, I quickly came to the realization that using separate modules would actually require users make an explicit choice wrt an extra jar. Especially considering that I could make Hibernate code make this determination programatically, I really did not like that aspect to using modules here. So I started looking for alternatives.

As I normally do, I started by thinking of just the ideal outside of any build structure or tool. So to my mind the best option here seemed to include compiling JDBC4 support targeting JDK 1.6 and JDBC3 support targeting JDK 1.4 and then bundling all that code into a single jar. The code which decides which feature-set to use uses reflection anyway, so there is no issue with having both in the same jar as long as only the correct classes actually get loaded (and anything else would be a bug in this determination code).

Well unfortunately it turns out that Maven does not really support such a setup. In the common case I think you'd set up multiple source directories within that main module and run different compilation executions against them with different compiler settings (source/target). This Maven explicitly disallows (see MCOMPILER-91 and its discussion for details).

Two workable solutions were presented to me (workable in that Maven could handle these):

  1. Use a single source directory, but configure 2 executions of the compiler plugin taking advantage of includes/excludes to define what to compile targeting 1.6 and 1.4. The issue here is that this is not good fit for IDEs.
  2. Split this into 3 modules (one each for JDB3 and JDBC4 support plus another for commonality to avoid circular dependencies with core). Core would then pull the compiled classes from these 3 modules into its jar. Seems overly complicated to me just to work around a self-imposed limitation of Maven. And sorry, I just don't see how this constitutes a messed up system as indicated in that Maven discussion.

Anyway, I really hope someone has other suggestions on better ways to handle this with Maven. Anyone?

21 comments:
 
22. Sep 2009, 14:46 CET | Link
Elias Ross

As a third option, I was thinking you could always build the patched version of the compile plugin as described on the mailing list. Build with that. Then send out a notice to everybody and tell them to use your version. Watch chaos ensue. ;-)

Maven really wants you to create lots of little bitty projects, which drives me crazy, but I suppose works out okay most of the time. So if I were you I'd go with 2.

ReplyQuote
 
22. Sep 2009, 15:08 CET | Link
Christoph Brill | egore(AT)gmx.de

I've used multiple source directories using the build-helper-maven-plugin. It was more or less the same than you want to do.

Another option is merging jars multiple jars into one executable jar using the maven-shade-plugin. This would enable you to develop the jdbc3 and jdbc4 as separate jars and generating a hibernate.jar which contains either of it (depending on the profile you've chosen).

I'd go this way: Build a jar containing both jdbc3 and jdbc4. At startup check which java version is running and load the appropriate jdbc classes. The core itself would only work against a common interface shared by the jdbc3 and jdbc4 classes.

Anyway, I really like to see that you ask for opinions from the community. Keep it up!

 
22. Sep 2009, 21:42 CET | Link
Christoph Brill wrote on Sep 22, 2009 09:08:
I've used multiple source directories using the build-helper-maven-plugin. It was more or less the same than you want to do.

Actually it does not from what I have been told because you cannot define separate compile settings for the various added source directories.

Christoph Brill wrote on Sep 22, 2009 09:08:
Another option is merging jars multiple jars into one executable jar using the maven-shade-plugin. This would enable you to develop the jdbc3 and jdbc4 as separate jars and generating a hibernate.jar which contains either of it (depending on the profile you've chosen).

The issue here imo is that really it is the hibernate-core jar where all this should go. But its a chicken-and-egg issue in regards to these jdbc3 and jdbc4 jars since they would depend on core, but core would need to depend on them in order to bundle their classes. This is essentially option number 2 I listed above, and as stated is way over-complicated for this situation imo.

Christoph Brill wrote on Sep 22, 2009 09:08:
I'd go this way: Build a jar containing both jdbc3 and jdbc4. At startup check which java version is running and load the appropriate jdbc classes. The core itself would only work against a common interface shared by the jdbc3 and jdbc4 classes.

Well this is largely what is being done (did you see the design wiki?). The problem is how to present this to the user in terms of jars they need to load into their environment.

 
03. Oct 2009, 03:28 CET | Link
Jaikiran
The #1 approach of using 2 separate compiler executions with include/exclude sounds easier to me. Any idea, what kind of issues does it causes with IDEs?
 
06. Oct 2009, 05:30 CET | Link
Jaikiran wrote on Oct 02, 2009 21:28:
The
  1. 1 approach of using 2 separate compiler executions with include/exclude sounds easier to me. Any idea, what kind of issues does it causes with IDEs?

IDEs use different terminology, but I'll use IntelliJ's as it matches pretty closely with Maven's here though the issue is the same in Eclipse as well. In IntelliJ, a project is made up of modules; it is in the modules where you define the JDK to use. Even though you can define multiple source directories within a module in IntelliJ, they all share the JDK assigned to that module.

So say you were to have JDK 1.4/1.5 (JDBC3) and JDK 1.6 (JDBC4) targetted code in the src/main/java directory. Aside from being a Maven hack, this is not the correct way to model this build. And an attempt to load that into an IDE is going to complain (if the module targets 1.4/1.5, the 1.6 targetted class will not compile, and visa versa).

 
06. Oct 2009, 08:05 CET | Link

So the second option sort of works using the shade plugin. You just have to be willing to accept some minor annoyances such as the fact that 3 modules (common, jdbc3 and jdbc4) are indeed needed, that these 3 modules still make there way into your local repo (and you have to explicitly configure the deplpy plugin to skip these modules or else they show up in the deploy repos too) and that this generally seems a bit more complex then it outght to be.

The verbiage I came to after discussing this with numerous folks is that we really have a 2-way set of dependencies here, but that the dependencies are isolated to phases. That is ideally JDBC3 and JDBC4 would have compile-time dependency on CORE, while CORE would have a package-time dependency on both JDBC3 and JDBC4 in order to package those classes into its jar. However Maven does not allow limiting dependencies to phases and even if it did it actually performs every lifecycle phase on each module before moving on to the next module.

 
21. Jun 2014, 16:08 CET | Link

Drones can be controlled manually on the ground or pre-programmed to run on their own to fly in the air like small airplanes. Theyre currently used for bombing attacks in Pakistan by the U.S. military and for entertainment. growing drone These days the market is filled with all types of bad credit car loans as well as deals in which enable individuals with bad credit to get a car. Most individuals however believe that many of them are only slick marketing strategies attempt to benefit from unsuspecting those who have credit car

 
12. Jul 2014, 18:19 CET | Link

A team is nothing without teamwork, and teamwork is hard to achieve when you can't get along with your team mates Crystal x tegal

22. Aug 2014, 09:21 CET | Link

Different well known waste that rolex submariner replica add some star artisan admirer bracelets in addition to silver or maybe sterling silver pearly white's or maybe grillz. There are hip hop over unity magnetic bracelets, topic snowchains, belt buckles, re-write solution happens to be in addition to chains. That cheap cartier replica watches is usually utilized clothed decrease or maybe decked out. Regardless the way it truly is utilized, jewelers usually are stunned by means of the way persons embraced this hip hop way of life. And so possibly there is not any from the pipeline near to which often purely solely simply just sole can certainly paying for brilliant excellent unfeigned replica chanel bags of which seeing that all right on quite breathtaking charges. This choice to help with excessive dilemma is usually without a doubt, there may be special purely on very best registered conglomeration next to which you may definitely not honorable buy the undoubtedly surprising fantastic straightforward shoes and boots by replica chanel bags although ceremony visit an extraordinary have the funds for exceptionally an incredible offer a good fake hublot significantly better charges. This bracelets manufactured for hoppers will never be elegant. Many people combine having all kinds connected with vogue record, and in addition they commonly also come in substantial sizing's in particular this diamond jewelry.

23. Aug 2014, 14:46 CET | Link
that

I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. venus factor workout

23. Aug 2014, 14:46 CET | Link
than what

Ctual product packaging and materials may contain more and different information than what is shown on our website. We recommend that you do not rely solely on the information presented and that you always read labels, warnings, and directions before using or consuming a product. venus factor login

23. Aug 2014, 14:47 CET | Link
know how

I have developed an application in seam and richfaces. Anyone please let me know how to change the background color of a page. Instead of white i want a different color. What should i do inorder to accomplish this. venus factor workout

 
29. Sep 2014, 04:41 CET | Link
jenny bolton

I have seen your awareness about this theme when you post it and it really gives an informational message to us readers. I am hoping that you will continue writing this kind of blog. Thanks for sharing this information. breast enlargement without surgery book

09. Oct 2014, 10:40 CET | Link

If he does (especially when he releases the new version in 2014), I'll be sure to post here and let everyone know.how to get the girlfriend activation system for free

14. Oct 2014, 10:15 CET | Link
officialworking00 | officialworking00(AT)gmail.com

I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details. Honda

14. Oct 2014, 12:51 CET | Link
asadalikhatri

The 21 Day Sugar Detox book is only available online through author Diane Sanfilippo's website and is NOT sold through Amazon, Barnes and Noble, or other traditional book sellers.paleo 21 day sugar detox desserts

15. Oct 2014, 14:13 CET | Link
asad

Our policy is to provide quality services to the highest local and international standards. We achieve this by maintaining a strong team of skillfully trained professionals that are provided with all the necessary materials to follow local and international procedures in various classifications.Legal Advocates

17. Oct 2014, 15:57 CET | Link

Thank you for serving the information is very helpful. And build hope for the future of bias present information that is more useful and insightful again...... mutelle et medicament

18. Oct 2014, 12:56 CET | Link
Sophia1525

You always deliver the best, sir. Whenever, I have read any of your articles, I always had fun. And I rated all of them as high quality. You are one of the best writers that I've read articles of. Sophia1525

 
20. Oct 2014, 11:44 CET | Link
pipde

This is a great article thanks for sharing this informative information. HD mxf files conversion software mxf converter pdf conversion to Office pdf to word

20. Oct 2014, 12:03 CET | Link
beof

This is a great article thanks for sharing this informative information. HD mxf files conversion software mxf converter pdf conversion to Office pdf to word the preview.

Post Comment