I don't want to Assign Persistence Unit Datasource

Hi,

Idea 6.0.4

I'm developping a JSE application that uses JPA. I'm creating several Java Modules and because I'm using JPA annotation and persistence.xml files, I've choosen to add a persistence unit to my module. Maybe that wasn't a good idea because now Idea doesn't allow me to compile due to so many "Assign Persistence Unit Datasource" errors. Idea wants me to map a datasource to my persistence unit, but I don't want to.

It is a JSE application without any datasource (I'm using transaction-type="RESOURCE_LOCAL" on persistence.xml file) and I don't know how to desactivate this intention/error checking with Idea.

Does anybody knows how to deactivate that ? Shall I not add persistence unit to a module and just deal with persistence.xml file on my own ?

Thanks,

Antonio

0
4 comments

Hello Antonio,

"DataSource ORM Annotations problems" inspection should be turned off.

Gregory Shrago


Antonio Goncalves wrote:

Hi,

Idea 6.0.4

I'm developping a JSE application that uses JPA. I'm creating several Java Modules and because I'm using JPA annotation and persistence.xml files, I've choosen to add a persistence unit to my module. Maybe that wasn't a good idea because now Idea doesn't allow me to compile due to so many "Assign Persistence Unit Datasource" errors. Idea wants me to map a datasource to my persistence unit, but I don't want to.

It is a JSE application without any datasource (I'm using transaction-type="RESOURCE_LOCAL" on persistence.xml file) and I don't know how to desactivate this intention/error checking with Idea.

Does anybody knows how to deactivate that ? Shall I not add persistence unit to a module and just deal with persistence.xml file on my own ?

Thanks,

Antonio

0

Hi Antonio,


It is a JSE application without any datasource (I'm using
transaction-type="RESOURCE_LOCAL" on persistence.xml file) and I don't
know how to desactivate this intention/error checking with Idea.

Does anybody knows how to deactivate that ? Shall I not add
persistence unit to a module and just deal with persistence.xml file
on my own ?


The datasource IDEA talks about is not the one you'd use when running the
code (so you'd still be running using resource_local, in your case). In order
to generate and validate the OR mappings, IDEA uses a cached set of table
descriptors, obtained from the database through a datasource (a datasource
you set up in idea where you specify what DB you go against, what schemas/tables
you work with, etc).

The only thing that's gonna end up in your persistence.xml file is an IDEA
specific property telling the IDE about that "datasource", basically what
tables to use for the entities in that persistence unit (harmelss for the
executed code, although one could argue that this piece of info could be
kept in another place).

Give it a try, the functionality is quite helpful.

HTH,
Andrei


0

Thanks for the answers. I'm using a iterative approach to create ORM mapping for my students. Because I'm creating tables, droping them because not suitable, and recreating new ones, I prefer just to get rid of the inspection.

Antonio

0

Hi,

I have added a data source through the Tools | Data Source option. I can see my tables... but are there any examples of the persistence.xml file?

The help seems to be a bit too succinct.

  • Map to database.

  • Map to EJB relationships. From the Project view right-click the unit name, expand the Generate Persistence Mapping menu and select By Entity Beans.

  • Manually populate persistence mappings by editing the appropriate XML descriptor files.


Thanks,
Chris

PS Using IDEA 6.0.2

Message was edited by:
Chris Kimpton

0

Please sign in to leave a comment.