[forge-dev] JPA facet isInstalled implementation
George Gastaldi
ggastald at redhat.com
Mon Jul 6 16:54:04 EDT 2015
Right, we need to make isInstalled() fast, good point.
I think it's ok to assume that the facet is installed by checking the
existence and the version attribute in the persistence.xml. Maybe we
could add a getPersistenceProvider() to JPAFacet to let the user know
which implementation is used in case it needs more info, WDYT?
Best Regards,
George Gastaldi
On 07/06/2015 05:39 PM, Ivan St. Ivanov wrote:
> You mean, listing all the existing persistence providers and call
> their listDependencies() method? This sounds correct. But I am not
> sure how it will perform. Remember, this routine will be called each
> time a new entity or new field command is run...
>
> On Mon, Jul 6, 2015 at 11:35 PM, George Gastaldi <ggastald at redhat.com
> <mailto:ggastald at redhat.com>> wrote:
>
> We already got these PersistenceProvider implementations. What if
> we added a isInstalled(Project) on top of them?
>
>
> -------- Mensagem original --------
> De: "Ivan St. Ivanov" <ivan.st.ivanov at gmail.com
> <mailto:ivan.st.ivanov at gmail.com>>
> Data: 06/07/2015 17:33 (GMT-03:00)
> Para: forge-dev List <forge-dev at lists.jboss.org
> <mailto:forge-dev at lists.jboss.org>>
> Assunto: Re: [forge-dev] JPA facet isInstalled implementation
>
>
> Well, besides adding this, we should think of adding also the
> openjpa dependency, also the hibernate impl dependency and also
> removing the Java EE 6 dependency. And we also have to make a more
> sophisticated check to make sure we apply 'or' instead of 'and'
> when checking for the presence of these dependencies...
>
> Too complex and error prone in my opinion, don't you think?
>
> On Mon, Jul 6, 2015 at 11:30 PM, George Gastaldi
> <ggastald at redhat.com <mailto:ggastald at redhat.com>> wrote:
>
> Right, so the easiest way to solve this is to add this
> dependency to the JPAFacet_2_0.getRequiredDependencies().
>
> But I am not opposed on your proposed change, as long as no
> compilation issues happen.
>
> Thanks,
> George Gastaldi
>
>
> -------- Mensagem original --------
> De: "Ivan St. Ivanov" <ivan.st.ivanov at gmail.com
> <mailto:ivan.st.ivanov at gmail.com>>
> Data: 06/07/2015 17:25 (GMT-03:00)
> Para: forge-dev List <forge-dev at lists.jboss.org
> <mailto:forge-dev at lists.jboss.org>>
> Assunto: Re: [forge-dev] JPA facet isInstalled implementation
>
>
> Hi George,
>
> As I mentioned, I am using Eclipselink and have directly the
> dependency org.eclipse.persistence:eclipselink. On top of
> that, I don't have the Java EE API dependency. My
> persistence.xml is fine.
>
> What I really want here is when I add a new field Forge to
> find out that this project has already persistence.xml and not
> try to rebuild it just because I am missing some dependencies
> in the pom.xml.
>
> Cheers,
> Ivan
>
> On Mon, Jul 6, 2015 at 11:19 PM, George Gastaldi
> <ggastald at redhat.com <mailto:ggastald at redhat.com>> wrote:
>
> Hey Ivan,
>
> It seems that in your case the JPA 2.0 classes are defined
> in a different JAR (a different groupId/artifactId) ?
> Your idea might work, however, just make sure that the
> version attribute in the persistence.xml defines the
> installed facet version (JPAFacet_2_0 when version="2.0"
> and JPAFacet_2_1 when version="2.1").
>
> Best Regards,
> George Gastaldi
>
>
> On 07/06/2015 05:13 PM, Ivan St. Ivanov wrote:
>> Hi George,
>>
>> My idea is the following: if you don't have
>> persistence.xml, then most probably you don't have the
>> dependencies either. Definitely the facet is not
>> installed, so Forge installs it for you by adding both
>> the persistence.xml and the dependencies.
>>
>> But if you have persistence.xml already in your project
>> in 99% of the cases you have already setup the
>> dependencies as well. So the facet is there and Forge
>> does not need to install it.
>>
>> Regards,
>> Ivan
>>
>> On Mon, Jul 6, 2015 at 11:06 PM, George Gastaldi
>> <ggastald at redhat.com <mailto:ggastald at redhat.com>> wrote:
>>
>> Hi Ivan,
>>
>> I am not sure this is enough. How can you assure that
>> no compilation errors would occur when @Entity or any
>> other JPA-related class is used?
>>
>> Best Regards,
>>
>> George Gastaldi
>>
>>
>> On 07/06/2015 05:02 PM, Ivan St. Ivanov wrote:
>>> Hi everybody,
>>>
>>> I am working on a project that is not mainstream
>>> Java EE. Its target is Tomcat, but it uses JPA 2.0
>>> (Eclipselink). I have tailored the dependencies in
>>> the pom.xml as well as the persistence.xml.
>>>
>>> And now I want to use Forge to add some fields to
>>> the existing entities. What I noticed is that when I
>>> run the jpa-new-field command for the first time, it
>>> also installs the JPA facet. Which in turns adds
>>> some unwanted dependencies to my pom.xml and
>>> completely overwrites persistence.xml.
>>>
>>> I dig into the code and found that the isInstalled
>>> method of the JPA Facet returns true when
>>> persistence.xml file does not exist and when pom.xml
>>> does not contain some dependencies. These
>>> dependencies are different for JPA 2.0 and 2.1, but
>>> are basically Hibernate JPA API and the Java EE API.
>>>
>>> As a result of this, projects that don't target Java
>>> EE or that use different artifacts for it or for JPA
>>> are going to get their poms polluted and their
>>> persistence.xml files overwritten.
>>>
>>> So my proposal is to change the isInstalled method
>>> to only check for the presence of persistence.xml.
>>> What do you think?
>>>
>>> Regards,
>>> Ivan
>>>
>>>
>>> _______________________________________________
>>> forge-dev mailing list
>>> forge-dev at lists.jboss.org <mailto:forge-dev at lists.jboss.org>
>>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>
>>
>> _______________________________________________
>> forge-dev mailing list
>> forge-dev at lists.jboss.org
>> <mailto:forge-dev at lists.jboss.org>
>> https://lists.jboss.org/mailman/listinfo/forge-dev
>>
>>
>>
>>
>> _______________________________________________
>> forge-dev mailing list
>> forge-dev at lists.jboss.org <mailto:forge-dev at lists.jboss.org>
>> https://lists.jboss.org/mailman/listinfo/forge-dev
>
>
> _______________________________________________
> forge-dev mailing list
> forge-dev at lists.jboss.org <mailto:forge-dev at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/forge-dev
>
>
>
> _______________________________________________
> forge-dev mailing list
> forge-dev at lists.jboss.org <mailto:forge-dev at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/forge-dev
>
>
>
> _______________________________________________
> forge-dev mailing list
> forge-dev at lists.jboss.org <mailto:forge-dev at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/forge-dev
>
>
>
>
> _______________________________________________
> forge-dev mailing list
> forge-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/forge-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/forge-dev/attachments/20150706/3cb1a981/attachment-0001.html
More information about the forge-dev
mailing list