[hibernate-dev] The PAR archive test case validity - PackagedEntityManagerTest

2016-03-09 Thread Vlad Mihalcea
Hi,

I have two tests in the PackagedEntityManagerTest unit test that fail on my
machine, but work just fine for everybody else.
It could be an OS thing or not, but during the check, I found hat we are
testing against an use case that is not found in the JPA spec.

The testExternalJar() creates an externaljar.jar and an explicitpar.par.

I found an old reference on the PAR archive (
http://radio-weblogs.com/0135826/2005/07/07.html) but the JPA 2.1 doesn't
mention anything about it.
The explicitpar.par contains the persistence.xml which contains a jar-file
attribute that references the externaljar.jar with an absolute path:

D:\Vlad\Work\GitHub\hibernate-orm\hibernate-entitymanager\target/packages/externaljar.jar

The JPA spec says that: "Such JAR files are specified relative to the
directory or jar file that contains the root of the persistence unit", and
gives several examples
for when using an EAR with or without a WAR.

While debugging, I found that the JarFileBasedArchiveDescriptor scans the
"explicitpar.par" and looks for:

if ( getEntryBasePrefix() != null && ! entryName.startsWith(
getEntryBasePrefix() ) ) {
continue;
}

where the getEntryBasePrefix() is
"D:/Vlad/Work/GitHub/hibernate-orm/hibernate-entitymanager/target/packages/externaljar.jar"

The way that JarFileBasedArchiveDescriptor is implemented matches the JPA
description.
Nevertheless, the scan cannot locate the jar, and the entities that are
contained in the "externaljar.jar" don't get loaded, and the test fails.

I can ignore this on my machine and just consider it a white noise, but I
wonder why we still check for PAR when we might want to have a test with an
EAR instead and relative paths.

Vlad
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev


Re: [hibernate-dev] The PAR archive test case validity - PackagedEntityManagerTest

2016-03-09 Thread Emmanuel Bernard
We usually strive on having functionalities work on both Java EE and
Java SE.
you example though shows a mix of forward and backslash in your
, is that expected ?

Emmanuel

On Wed 2016-03-09 17:05, Vlad Mihalcea wrote:
> Hi,
> 
> I have two tests in the PackagedEntityManagerTest unit test that fail on my
> machine, but work just fine for everybody else.
> It could be an OS thing or not, but during the check, I found hat we are
> testing against an use case that is not found in the JPA spec.
> 
> The testExternalJar() creates an externaljar.jar and an explicitpar.par.
> 
> I found an old reference on the PAR archive (
> http://radio-weblogs.com/0135826/2005/07/07.html) but the JPA 2.1 doesn't
> mention anything about it.
> The explicitpar.par contains the persistence.xml which contains a jar-file
> attribute that references the externaljar.jar with an absolute path:
> 
> D:\Vlad\Work\GitHub\hibernate-orm\hibernate-entitymanager\target/packages/externaljar.jar
> 
> The JPA spec says that: "Such JAR files are specified relative to the
> directory or jar file that contains the root of the persistence unit", and
> gives several examples
> for when using an EAR with or without a WAR.
> 
> While debugging, I found that the JarFileBasedArchiveDescriptor scans the
> "explicitpar.par" and looks for:
> 
> if ( getEntryBasePrefix() != null && ! entryName.startsWith(
> getEntryBasePrefix() ) ) {
> continue;
> }
> 
> where the getEntryBasePrefix() is
> "D:/Vlad/Work/GitHub/hibernate-orm/hibernate-entitymanager/target/packages/externaljar.jar"
> 
> The way that JarFileBasedArchiveDescriptor is implemented matches the JPA
> description.
> Nevertheless, the scan cannot locate the jar, and the entities that are
> contained in the "externaljar.jar" don't get loaded, and the test fails.
> 
> I can ignore this on my machine and just consider it a white noise, but I
> wonder why we still check for PAR when we might want to have a test with an
> EAR instead and relative paths.
> 
> Vlad
> ___
> hibernate-dev mailing list
> hibernate-dev@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev


Re: [hibernate-dev] The PAR archive test case validity - PackagedEntityManagerTest

2016-03-09 Thread Vlad Mihalcea
Hi,

The part is backslashes comes from the absolute path set by Gradle when
supplying the module OS folder.
The right part containing slashes is the one set in persistence.xml.
I'll try to replace backslashes with slashes and see how it goes.

I was curious if people use the jar-file with absolute paths because the
JPA spec only implies it in the context of relative paths inside an EAR or
WAR.
As for PAR, I guess that was included in some JPA 1.0 draft but it got
rejected in the end, right?

Vlad




On Wed, Mar 9, 2016 at 6:39 PM, Emmanuel Bernard 
wrote:

> We usually strive on having functionalities work on both Java EE and
> Java SE.
> you example though shows a mix of forward and backslash in your
> , is that expected ?
>
> Emmanuel
>
> On Wed 2016-03-09 17:05, Vlad Mihalcea wrote:
> > Hi,
> >
> > I have two tests in the PackagedEntityManagerTest unit test that fail on
> my
> > machine, but work just fine for everybody else.
> > It could be an OS thing or not, but during the check, I found hat we are
> > testing against an use case that is not found in the JPA spec.
> >
> > The testExternalJar() creates an externaljar.jar and an explicitpar.par.
> >
> > I found an old reference on the PAR archive (
> > http://radio-weblogs.com/0135826/2005/07/07.html) but the JPA 2.1
> doesn't
> > mention anything about it.
> > The explicitpar.par contains the persistence.xml which contains a
> jar-file
> > attribute that references the externaljar.jar with an absolute path:
> >
> >
> D:\Vlad\Work\GitHub\hibernate-orm\hibernate-entitymanager\target/packages/externaljar.jar
> >
> > The JPA spec says that: "Such JAR files are specified relative to the
> > directory or jar file that contains the root of the persistence unit",
> and
> > gives several examples
> > for when using an EAR with or without a WAR.
> >
> > While debugging, I found that the JarFileBasedArchiveDescriptor scans the
> > "explicitpar.par" and looks for:
> >
> > if ( getEntryBasePrefix() != null && ! entryName.startsWith(
> > getEntryBasePrefix() ) ) {
> > continue;
> > }
> >
> > where the getEntryBasePrefix() is
> >
> "D:/Vlad/Work/GitHub/hibernate-orm/hibernate-entitymanager/target/packages/externaljar.jar"
> >
> > The way that JarFileBasedArchiveDescriptor is implemented matches the JPA
> > description.
> > Nevertheless, the scan cannot locate the jar, and the entities that are
> > contained in the "externaljar.jar" don't get loaded, and the test fails.
> >
> > I can ignore this on my machine and just consider it a white noise, but I
> > wonder why we still check for PAR when we might want to have a test with
> an
> > EAR instead and relative paths.
> >
> > Vlad
> > ___
> > hibernate-dev mailing list
> > hibernate-dev@lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev


Re: [hibernate-dev] The PAR archive test case validity - PackagedEntityManagerTest

2016-03-09 Thread Sanne Grinovero
I remember JBoss had "HAR" deployments to package Hibernate models and
PU definitions.. as far as I know this was a JBoss only thing, it
wouldn't surprise me if other app servers experimented with similar
non-standardized archives.

https://docs.jboss.org/jbossas/jboss4guide/r3/html/ch13.html

On 9 March 2016 at 18:39, Vlad Mihalcea  wrote:
> Hi,
>
> The part is backslashes comes from the absolute path set by Gradle when
> supplying the module OS folder.
> The right part containing slashes is the one set in persistence.xml.
> I'll try to replace backslashes with slashes and see how it goes.
>
> I was curious if people use the jar-file with absolute paths because the
> JPA spec only implies it in the context of relative paths inside an EAR or
> WAR.
> As for PAR, I guess that was included in some JPA 1.0 draft but it got
> rejected in the end, right?
>
> Vlad
>
>
>
>
> On Wed, Mar 9, 2016 at 6:39 PM, Emmanuel Bernard 
> wrote:
>
>> We usually strive on having functionalities work on both Java EE and
>> Java SE.
>> you example though shows a mix of forward and backslash in your
>> , is that expected ?
>>
>> Emmanuel
>>
>> On Wed 2016-03-09 17:05, Vlad Mihalcea wrote:
>> > Hi,
>> >
>> > I have two tests in the PackagedEntityManagerTest unit test that fail on
>> my
>> > machine, but work just fine for everybody else.
>> > It could be an OS thing or not, but during the check, I found hat we are
>> > testing against an use case that is not found in the JPA spec.
>> >
>> > The testExternalJar() creates an externaljar.jar and an explicitpar.par.
>> >
>> > I found an old reference on the PAR archive (
>> > http://radio-weblogs.com/0135826/2005/07/07.html) but the JPA 2.1
>> doesn't
>> > mention anything about it.
>> > The explicitpar.par contains the persistence.xml which contains a
>> jar-file
>> > attribute that references the externaljar.jar with an absolute path:
>> >
>> >
>> D:\Vlad\Work\GitHub\hibernate-orm\hibernate-entitymanager\target/packages/externaljar.jar
>> >
>> > The JPA spec says that: "Such JAR files are specified relative to the
>> > directory or jar file that contains the root of the persistence unit",
>> and
>> > gives several examples
>> > for when using an EAR with or without a WAR.
>> >
>> > While debugging, I found that the JarFileBasedArchiveDescriptor scans the
>> > "explicitpar.par" and looks for:
>> >
>> > if ( getEntryBasePrefix() != null && ! entryName.startsWith(
>> > getEntryBasePrefix() ) ) {
>> > continue;
>> > }
>> >
>> > where the getEntryBasePrefix() is
>> >
>> "D:/Vlad/Work/GitHub/hibernate-orm/hibernate-entitymanager/target/packages/externaljar.jar"
>> >
>> > The way that JarFileBasedArchiveDescriptor is implemented matches the JPA
>> > description.
>> > Nevertheless, the scan cannot locate the jar, and the entities that are
>> > contained in the "externaljar.jar" don't get loaded, and the test fails.
>> >
>> > I can ignore this on my machine and just consider it a white noise, but I
>> > wonder why we still check for PAR when we might want to have a test with
>> an
>> > EAR instead and relative paths.
>> >
>> > Vlad
>> > ___
>> > hibernate-dev mailing list
>> > hibernate-dev@lists.jboss.org
>> > https://lists.jboss.org/mailman/listinfo/hibernate-dev
>>
> ___
> hibernate-dev mailing list
> hibernate-dev@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev


Re: [hibernate-dev] The PAR archive test case validity - PackagedEntityManagerTest

2016-03-09 Thread Steve Ebersole
A PAR is just an archive with a META-INF/persistence.xml file in it.  The
JPA spec does cover this.  The extension is irrelevant.

On Wed, Mar 9, 2016 at 4:08 PM Sanne Grinovero  wrote:

> I remember JBoss had "HAR" deployments to package Hibernate models and
> PU definitions.. as far as I know this was a JBoss only thing, it
> wouldn't surprise me if other app servers experimented with similar
> non-standardized archives.
>
> https://docs.jboss.org/jbossas/jboss4guide/r3/html/ch13.html
>
> On 9 March 2016 at 18:39, Vlad Mihalcea  wrote:
> > Hi,
> >
> > The part is backslashes comes from the absolute path set by Gradle when
> > supplying the module OS folder.
> > The right part containing slashes is the one set in persistence.xml.
> > I'll try to replace backslashes with slashes and see how it goes.
> >
> > I was curious if people use the jar-file with absolute paths because the
> > JPA spec only implies it in the context of relative paths inside an EAR
> or
> > WAR.
> > As for PAR, I guess that was included in some JPA 1.0 draft but it got
> > rejected in the end, right?
> >
> > Vlad
> >
> >
> >
> >
> > On Wed, Mar 9, 2016 at 6:39 PM, Emmanuel Bernard  >
> > wrote:
> >
> >> We usually strive on having functionalities work on both Java EE and
> >> Java SE.
> >> you example though shows a mix of forward and backslash in your
> >> , is that expected ?
> >>
> >> Emmanuel
> >>
> >> On Wed 2016-03-09 17:05, Vlad Mihalcea wrote:
> >> > Hi,
> >> >
> >> > I have two tests in the PackagedEntityManagerTest unit test that fail
> on
> >> my
> >> > machine, but work just fine for everybody else.
> >> > It could be an OS thing or not, but during the check, I found hat we
> are
> >> > testing against an use case that is not found in the JPA spec.
> >> >
> >> > The testExternalJar() creates an externaljar.jar and an
> explicitpar.par.
> >> >
> >> > I found an old reference on the PAR archive (
> >> > http://radio-weblogs.com/0135826/2005/07/07.html) but the JPA 2.1
> >> doesn't
> >> > mention anything about it.
> >> > The explicitpar.par contains the persistence.xml which contains a
> >> jar-file
> >> > attribute that references the externaljar.jar with an absolute path:
> >> >
> >> >
> >>
> D:\Vlad\Work\GitHub\hibernate-orm\hibernate-entitymanager\target/packages/externaljar.jar
> >> >
> >> > The JPA spec says that: "Such JAR files are specified relative to the
> >> > directory or jar file that contains the root of the persistence unit",
> >> and
> >> > gives several examples
> >> > for when using an EAR with or without a WAR.
> >> >
> >> > While debugging, I found that the JarFileBasedArchiveDescriptor scans
> the
> >> > "explicitpar.par" and looks for:
> >> >
> >> > if ( getEntryBasePrefix() != null && ! entryName.startsWith(
> >> > getEntryBasePrefix() ) ) {
> >> > continue;
> >> > }
> >> >
> >> > where the getEntryBasePrefix() is
> >> >
> >>
> "D:/Vlad/Work/GitHub/hibernate-orm/hibernate-entitymanager/target/packages/externaljar.jar"
> >> >
> >> > The way that JarFileBasedArchiveDescriptor is implemented matches the
> JPA
> >> > description.
> >> > Nevertheless, the scan cannot locate the jar, and the entities that
> are
> >> > contained in the "externaljar.jar" don't get loaded, and the test
> fails.
> >> >
> >> > I can ignore this on my machine and just consider it a white noise,
> but I
> >> > wonder why we still check for PAR when we might want to have a test
> with
> >> an
> >> > EAR instead and relative paths.
> >> >
> >> > Vlad
> >> > ___
> >> > hibernate-dev mailing list
> >> > hibernate-dev@lists.jboss.org
> >> > https://lists.jboss.org/mailman/listinfo/hibernate-dev
> >>
> > ___
> > hibernate-dev mailing list
> > hibernate-dev@lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/hibernate-dev
> ___
> hibernate-dev mailing list
> hibernate-dev@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev


Re: [hibernate-dev] The PAR archive test case validity - PackagedEntityManagerTest

2016-03-09 Thread Vlad Mihalcea
Hi,

I managed to find what caused this test to start failing. The reason is
this commit:

Commit: 5c77f279afaecb505f7a22bfa05c172b493096bd [5c77f27]
Parents: 8670b4211e
Author: Steve Ebersole 
Date: Tuesday, January 12, 2016 11:21:54 PM
Commit Date: Tuesday, January 12, 2016 11:22:19 PM
Labels: HEAD
HHH-4161 - persistence.xml  not following JSR220 spec

This commit was done for this issue
https://hibernate.atlassian.net/browse/HHH-4161.

The problem is that StandardArchiveDescriptorFactory#adjustJarFileEntryUrl
applies even when we don't deal with relative paths.

In the context of the PackagedEntityManagerTest#testExternalJar test, we
have a PAR whose persistence.xml uses a jar-file that's declared with an
absolute path
(file:D:/Vlad/Work/GitHub/hibernate-orm/hibernate-entitymanager/target/packages/externaljar.jar),
and the jar resides next to the PAR (it's not embedded).

If I disable the check,
StandardArchiveDescriptorFactory#adjustJarFileEntryUrl returns the URL as
is
(file:D:/Vlad/Work/GitHub/hibernate-orm/hibernate-entitymanager/target/packages/externaljar.jar),
which is passed to the ArchiveDescriptor.

But the check is enabled because the URL has a file protocol:

final boolean check = StringHelper.isEmpty( protocol )
|| "file".equals( protocol )
|| "vfszip".equals( protocol )
|| "vfsfile".equals( protocol );

So, StandardArchiveDescriptorFactory#adjustJarFileEntryUrl will return this
instead:

jar:file://D:\Vlad\Work\GitHub\hibernate-orm\hibernate-entitymanager\target\packages\explicitpar.par!/D:/Vlad/Work/GitHub/hibernate-orm/hibernate-entitymanager/target/packages/externaljar.jar

And, the jar will not be located because this is not an embedded jar use
case.

I wonder how is it working on Linux and it only fails on Windows?

Can someone run this test and check what's the return value from the
StandardArchiveDescriptorFactory#adjustJarFileEntryUrl method when running
the PackagedEntityManagerTest#testExternalJar test?

Thanks,
Vlad


On Thu, Mar 10, 2016 at 12:49 AM, Steve Ebersole 
wrote:

> A PAR is just an archive with a META-INF/persistence.xml file in it.  The
> JPA spec does cover this.  The extension is irrelevant.
>
> On Wed, Mar 9, 2016 at 4:08 PM Sanne Grinovero 
> wrote:
>
>> I remember JBoss had "HAR" deployments to package Hibernate models and
>> PU definitions.. as far as I know this was a JBoss only thing, it
>> wouldn't surprise me if other app servers experimented with similar
>> non-standardized archives.
>>
>> https://docs.jboss.org/jbossas/jboss4guide/r3/html/ch13.html
>>
>> On 9 March 2016 at 18:39, Vlad Mihalcea  wrote:
>> > Hi,
>> >
>> > The part is backslashes comes from the absolute path set by Gradle when
>> > supplying the module OS folder.
>> > The right part containing slashes is the one set in persistence.xml.
>> > I'll try to replace backslashes with slashes and see how it goes.
>> >
>> > I was curious if people use the jar-file with absolute paths because the
>> > JPA spec only implies it in the context of relative paths inside an EAR
>> or
>> > WAR.
>> > As for PAR, I guess that was included in some JPA 1.0 draft but it got
>> > rejected in the end, right?
>> >
>> > Vlad
>> >
>> >
>> >
>> >
>> > On Wed, Mar 9, 2016 at 6:39 PM, Emmanuel Bernard <
>> emman...@hibernate.org>
>> > wrote:
>> >
>> >> We usually strive on having functionalities work on both Java EE and
>> >> Java SE.
>> >> you example though shows a mix of forward and backslash in your
>> >> , is that expected ?
>> >>
>> >> Emmanuel
>> >>
>> >> On Wed 2016-03-09 17:05, Vlad Mihalcea wrote:
>> >> > Hi,
>> >> >
>> >> > I have two tests in the PackagedEntityManagerTest unit test that
>> fail on
>> >> my
>> >> > machine, but work just fine for everybody else.
>> >> > It could be an OS thing or not, but during the check, I found hat we
>> are
>> >> > testing against an use case that is not found in the JPA spec.
>> >> >
>> >> > The testExternalJar() creates an externaljar.jar and an
>> explicitpar.par.
>> >> >
>> >> > I found an old reference on the PAR archive (
>> >> > http://radio-weblogs.com/0135826/2005/07/07.html) but the JPA 2.1
>> >> doesn't
>> >> > mention anything about it.
>> >> > The explicitpar.par contains the persistence.xml which contains a
>> >> jar-file
>> >> > attribute that references the externaljar.jar with an absolute path:
>> >> >
>> >> >
>> >>
>> D:\Vlad\Work\GitHub\hibernate-orm\hibernate-entitymanager\target/packages/externaljar.jar
>> >> >
>> >> > The JPA spec says that: "Such JAR files are specified relative to the
>> >> > directory or jar file that contains the root of the persistence
>> unit",
>> >> and
>> >> > gives several examples
>> >> > for when using an EAR with or without a WAR.
>> >> >
>> >> > While debugging, I found that the JarFileBasedArchiveDescriptor
>> scans the
>> >> > "explicitpar.par" and looks for:
>> >> >
>> >> > if ( getEntryBasePrefix() != null && ! entryName.startsWith(
>> >> > getEntryBasePrefix() ) ) {
>> >> > continue;
>> >> > }
>> >> 

Re: [hibernate-dev] HHH-8999/HHH-10413 and Comparable IDs

2016-03-09 Thread Gail Badner
I've created a pull request implements option A) (creates comparators
for PrimitiveByteArrayTypeDescriptor,
PrimitiveCharacterArrayTypeDescriptor, ByteArrayTypeDescriptor, and
CharacterArrayTypeDescriptor.

I'm still not sure if it makes sense to have a comparators for arrays.

Steve, please take a look at the pull request [1] and let me know if this
looks reasonable to you.

Thanks,
Gail

[1] https://github.com/hibernate/hibernate-orm/pull/1294

On Thu, Mar 3, 2016 at 2:44 AM, Gail Badner  wrote:

> Missed something. Please see below...
>
> On Wed, Mar 2, 2016 at 11:49 PM, Gail Badner  wrote:
>
>> ExecutableList#add attempts to keep track of whether the Executable
>> objects are sorted. [1]
>>
>> Except for entity insert actions (which use InsertActionSorter),
>> ExecutableList#add uses the following to determine if adding the current
>> Executable to the end invalidates the sort:
>>
>> if ( previousLast != null && previousLast.compareTo( executable ) > 0 ) {
>> sorted = false;
>> }
>>
>> EntityAction#compareTo compares the IDs for the current and previous
>> EntityAction if they have different entity names; similarly,
>> CollectionAction compares the collection keys for the current and previous
>> CollectionAction if they have different entity names.
>>
>> In most cases, the ID class implements Comparable, although I don't know
>> of any requirement that says this needs to be true.
>>
>> This breaks down when a byte[] ID is used as described by HHH-8999. The
>> reason is that AbstractTypeDescriptor#comparator is null because it is
>> assigned like this:
>>
>> this.comparator = Comparable.class.isAssignableFrom( type )
>> ? (Comparator) ComparableComparator.INSTANCE
>> : null;
>>
>> PrimitiveByteArrayTypeDescriptor does not override
>> AbstractTypeDescriptor#getComparator, so null is returned ultimately
>> causing a NullPointerException in AbstractStandardBasicType#compare:
>>
>> public final int compare(Object x, Object y) {
>> return javaTypeDescriptor.getComparator().compare( (T) x, (T) y );
>> }
>>
>> The same happens for PrimitiveCharacterArrayTypeDescriptor,
>> ByteArrayTypeDescriptor, and CharacterArrayTypeDescriptor. Are there others?
>>
>> According to HHH-10413, this also affects version attributes.
>>
>> Here are a couple of alternatives:
>>
>> A) create comparators for PrimitiveCharacterArrayTypeDescriptor,
>> ByteArrayTypeDescriptor, and CharacterArrayTypeDescriptor.
>>
>
> PrimitiveByteArrayTypeDescript should also be in the list for A).
>
>
>>
>>
>> B) Change AbstractTypeDescriptor#comparator to:
>>
>> this.comparator = Comparable.class.isAssignableFrom( type )
>> ? (Comparator) ComparableComparator.INSTANCE
>> : IncomparableComparator.INSTANCE;
>>
>> IncomparableComparator#compare always returns 0, so that comparison would
>> never invalidate the sort.
>>
>>
> B) is not acceptable for PrimitiveByteArrayTypeDescripter because a
> version attribute can be of type byte[]. We definitely do not want all
> byte[] version values to compare as equal. A Comparator needs to be
> implemented at least for PrimitiveByteArrayTypeDescripter.
>
> The following question only applies to
> PrimitiveCharacterArrayTypeDescriptor, ByteArrayTypeDescriptor, and
> CharacterArrayTypeDescriptor.
>
>
>> Does it make sense to sort Executable objects by an ID or collection key
>> that is an array? In other words, would such IDs be generated in a natural
>> order? If not, I think B) makes more sense.
>>
>
>> Thoughts?
>>
>> Thanks,
>> Gail
>>
>> [1]
>> https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/engine/spi/ExecutableList.java#L194
>>
>
>
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev


Re: [hibernate-dev] The PAR archive test case validity - PackagedEntityManagerTest

2016-03-09 Thread Vlad Mihalcea
The fix goes like this:

if ( filePart.startsWith( "/" ) || new File(url.getFile()).isAbsolute() ) {
   // the URL is already an absolute form
   return url;
}

The reason why it works on Linux/Macs is that absolute paths start with "/".

With this fix works on Windows too, but I wonder if we shouldn't have
it like this instead:

if ( new File(url.getFile()).isAbsolute() ) {
   // the URL is already an absolute form
   return url;
}

I think this should work on any OS, right?

Vlad


On Thu, Mar 10, 2016 at 9:18 AM, Vlad Mihalcea 
wrote:

> Hi,
>
> I managed to find what caused this test to start failing. The reason is
> this commit:
>
> Commit: 5c77f279afaecb505f7a22bfa05c172b493096bd [5c77f27]
> Parents: 8670b4211e
> Author: Steve Ebersole 
> Date: Tuesday, January 12, 2016 11:21:54 PM
> Commit Date: Tuesday, January 12, 2016 11:22:19 PM
> Labels: HEAD
> HHH-4161 - persistence.xml  not following JSR220 spec
>
> This commit was done for this issue
> https://hibernate.atlassian.net/browse/HHH-4161.
>
> The problem is that StandardArchiveDescriptorFactory#adjustJarFileEntryUrl
> applies even when we don't deal with relative paths.
>
> In the context of the PackagedEntityManagerTest#testExternalJar test, we
> have a PAR whose persistence.xml uses a jar-file that's declared with an
> absolute path
> (file:D:/Vlad/Work/GitHub/hibernate-orm/hibernate-entitymanager/target/packages/externaljar.jar),
> and the jar resides next to the PAR (it's not embedded).
>
> If I disable the check,
> StandardArchiveDescriptorFactory#adjustJarFileEntryUrl returns the URL as
> is
> (file:D:/Vlad/Work/GitHub/hibernate-orm/hibernate-entitymanager/target/packages/externaljar.jar),
> which is passed to the ArchiveDescriptor.
>
> But the check is enabled because the URL has a file protocol:
>
> final boolean check = StringHelper.isEmpty( protocol )
> || "file".equals( protocol )
> || "vfszip".equals( protocol )
> || "vfsfile".equals( protocol );
>
> So, StandardArchiveDescriptorFactory#adjustJarFileEntryUrl will return
> this instead:
>
>
> jar:file://D:\Vlad\Work\GitHub\hibernate-orm\hibernate-entitymanager\target\packages\explicitpar.par!/D:/Vlad/Work/GitHub/hibernate-orm/hibernate-entitymanager/target/packages/externaljar.jar
>
> And, the jar will not be located because this is not an embedded jar use
> case.
>
> I wonder how is it working on Linux and it only fails on Windows?
>
> Can someone run this test and check what's the return value from the
> StandardArchiveDescriptorFactory#adjustJarFileEntryUrl method when running
> the PackagedEntityManagerTest#testExternalJar test?
>
> Thanks,
> Vlad
>
>
> On Thu, Mar 10, 2016 at 12:49 AM, Steve Ebersole 
> wrote:
>
>> A PAR is just an archive with a META-INF/persistence.xml file in it.  The
>> JPA spec does cover this.  The extension is irrelevant.
>>
>> On Wed, Mar 9, 2016 at 4:08 PM Sanne Grinovero 
>> wrote:
>>
>>> I remember JBoss had "HAR" deployments to package Hibernate models and
>>> PU definitions.. as far as I know this was a JBoss only thing, it
>>> wouldn't surprise me if other app servers experimented with similar
>>> non-standardized archives.
>>>
>>> https://docs.jboss.org/jbossas/jboss4guide/r3/html/ch13.html
>>>
>>> On 9 March 2016 at 18:39, Vlad Mihalcea  wrote:
>>> > Hi,
>>> >
>>> > The part is backslashes comes from the absolute path set by Gradle when
>>> > supplying the module OS folder.
>>> > The right part containing slashes is the one set in persistence.xml.
>>> > I'll try to replace backslashes with slashes and see how it goes.
>>> >
>>> > I was curious if people use the jar-file with absolute paths because
>>> the
>>> > JPA spec only implies it in the context of relative paths inside an
>>> EAR or
>>> > WAR.
>>> > As for PAR, I guess that was included in some JPA 1.0 draft but it got
>>> > rejected in the end, right?
>>> >
>>> > Vlad
>>> >
>>> >
>>> >
>>> >
>>> > On Wed, Mar 9, 2016 at 6:39 PM, Emmanuel Bernard <
>>> emman...@hibernate.org>
>>> > wrote:
>>> >
>>> >> We usually strive on having functionalities work on both Java EE and
>>> >> Java SE.
>>> >> you example though shows a mix of forward and backslash in your
>>> >> , is that expected ?
>>> >>
>>> >> Emmanuel
>>> >>
>>> >> On Wed 2016-03-09 17:05, Vlad Mihalcea wrote:
>>> >> > Hi,
>>> >> >
>>> >> > I have two tests in the PackagedEntityManagerTest unit test that
>>> fail on
>>> >> my
>>> >> > machine, but work just fine for everybody else.
>>> >> > It could be an OS thing or not, but during the check, I found hat
>>> we are
>>> >> > testing against an use case that is not found in the JPA spec.
>>> >> >
>>> >> > The testExternalJar() creates an externaljar.jar and an
>>> explicitpar.par.
>>> >> >
>>> >> > I found an old reference on the PAR archive (
>>> >> > http://radio-weblogs.com/0135826/2005/07/07.html) but the JPA 2.1
>>> >> doesn't
>>> >> > mention anything about it.
>>> >> > The explicitpar.par contains the persistence.xml which contains a
>>> >> jar-file
>>> >> > attribute tha