How do I enable JPA support?

I somehow managed to disable JPA support I think, because none of the fields in my entities have that little 'this is a persistent field' icon next to it.

Where do I turn JPA support back on again?

S.

9 comments

Hello Stefan,

Here are some things to look at:

1. if you use Selena EAP check that JPA facet is configured for the module.

2. persistence.xml should be properly configured:
If the PU is in a Java Module be sure that persistence.xml is in
<SRC-ROOT>/META-INF otherwise it has to be specified as deployment
descriptor in module settings (Web/Ejb Module Settings tab).

3. PU definition in persistence.xml should list all ORM XMLs and (in
case "exclude-unlisted-classes" is true) all annotated classes.

PS Java EE structure view is the other way to see if PU is recognized.

Gregory Shrago



Stefan Arentz wrote:

I somehow managed to disable JPA support I think, because none of the fields in my entities have that little 'this is a persistent field' icon next to it.

Where do I turn JPA support back on again?

S.


0

Hello Stefan,

Here are some things to look at:

1. if you use Selena EAP check that JPA facet is
configured for the module.


Maven generates my (complex multi-module) projects. Is there a way to enable a facet on a module in an existing project?

2. persistence.xml should be properly configured:
If the PU is in a Java Module be sure that
persistence.xml is in
<SRC-ROOT>/META-INF otherwise it has to be specified
as deployment
descriptor in module settings (Web/Ejb Module
Settings tab).


I'm working on a J2SE project with Spring and JPA. And my persistence.xml is not in a standard place. It is on the classpath though, like classpath:com/foo/Repository-persistence.xml

S.

0

Stefan Arentz wrote:
>> Hello Stefan,
>>
>> Here are some things to look at:
>>
>> 1. if you use Selena EAP check that JPA facet is
>> configured for the module.


Maven generates my (complex multi-module) projects. Is there a way to enable a facet on a module in an existing project?


In Module settings dialog RMB on module, select Add->Facet->JPA


>> 2. persistence.xml should be properly configured:
>> If the PU is in a Java Module be sure that
>> persistence.xml is in
>> <SRC-ROOT>/META-INF otherwise it has to be specified
>> as deployment
>> descriptor in module settings (Web/Ejb Module
>> Settings tab).


I'm working on a J2SE project with Spring and JPA. And my persistence.xml is not in a standard place. It is on the classpath though, like classpath:com/foo/Repository-persistence.xml


Unfortunately in the current EAP non-standard descriptor places are
supported only in EJB/Web modules.
As a workaround you can create EJB 3.0 module with persistence.xml as
the only descriptor.


S.

0

Stefan Arentz wrote:
>> Hello Stefan,
>>
>> Here are some things to look at:
>>
>> 1. if you use Selena EAP check that JPA facet is
>> configured for the module.


Maven generates my (complex multi-module) projects.

Is there a way to enable a facet on a module in an
existing project?

In Module settings dialog RMB on module, select
Add->Facet->JPA


Ahh. Never found that one :)

>> 2. persistence.xml should be properly configured:
>> If the PU is in a Java Module be sure that
>> persistence.xml is in
>> <SRC-ROOT>/META-INF otherwise it has to be
specified
>> as deployment
>> descriptor in module settings (Web/Ejb Module
>> Settings tab).


I'm working on a J2SE project with Spring and JPA.

And my persistence.xml is not in a standard place. It
is on the classpath though, like
classpath:com/foo/Repository-persistence.xml

Unfortunately in the current EAP non-standard
descriptor places are
supported only in EJB/Web modules.
As a workaround you can create EJB 3.0 module with
persistence.xml as
the only descriptor.


Hmm. Is this something you are willing to support for the final release? JPA is supposed to work in a J2SE environment too, and I think many projects do that actually. Mostly because of Spring I assume, since that looks just like J2SE from a code pov.

S.

0

Hmm. Is this something you are willing to support for the final release? JPA is supposed to work in a J2SE environment too, and I think many projects do that actually. Mostly because of Spring I assume, since that looks just like J2SE from a code pov.

S.


Sure

0

I'm using 7.0M1, and sometimes an entity class will lose its JPA icons and as such other entities that map relations will show these associations as errors. The fix appears to be pressing return on the @Table or @Entity annotation which seems to trigger IDEA to parse it again or something.

A bit annoying!

0

dilator wrote:

I'm using 7.0M1, and sometimes an entity class will lose its JPA icons and as such other entities that map relations will show these associations as errors. The fix appears to be pressing return on the @Table or @Entity annotation which seems to trigger IDEA to parse it again or something.

A bit annoying!


Is this reproducible?

0

I've seen similar behavior in 7.0M1. If you've got an entity all setup with PU and nifty icons and no red lines and then change the database schema underneath of it, two things happen. One is the data source does not see the change until it is refreshed. Two is the entity does not show red lines unless you change an annotation and get the IDE to re-parse the file.

Since one of the nice things about IntelliJ how it always sees changes to Java, XML, etc. files without having to sync with file system it would be nice to get the same behavior automatically sync'ing with the database without having to think about it. Parsing all the entities on data source refresh might be a good first step, though.

That said 7.0M1 has some really great JPA things going on. Thank you, and keep up the good work folks.

--
Tim

0

I'll have a go at creating a testcase for it...

0

Please sign in to leave a comment.