IDEA JPA console and $ separator

You have in particular
https://youtrack.cuba-platform.com/issue/STUDIO-5681
In platform prior to 7 $ was used everywhere

Starting with 7 it’s said:
It is recommended to use underscore instead of “$” to separate namespace and class in entity names, for example sales_Customer.

So when I tried to use IDEA’s JPA console for projects based on version prior to 7 I got errors
image

Starting with version 7 I get nothing
image

But at least I think problem was that you used to use $ as separator and $ is fobidden symbol
Maybe you should use _ (underscore) everywhere instead of $ and should make IDEA’s JPA console work ? And so you won’t have to disable or mess with IDEA’s JPA syntax parsing?
(somewhere here I used to read that IDEA’s console doesn’t use some of your custom JPA’s extension names translator or whatever And the only need in such translator is using $ …)
Why $? Historically… I’ve always wondered…

But at least I think problem was that you used to use $ as separator and $ is fobidden symbol

$ is permitted symbol in all JPA implementations.

Maybe you should use _ (underscore) everywhere instead of $ and should make IDEA’s JPA console work

We should not. Existing databases contain a lot of $ identifiers (as serialized forms, snapshots, configs, custom data) and we do not want to break compatibility. In the meanwhile we will give you an option to disable built-in IDEA Ultimate inspection, because it is wrong. New projects use _ as prefix by default.

Also, we are planning to release JPA console support in Studio 8 Release (but it requires platform 7.1). You can try it right now using Nightly builds.

Read more about setting up JPA console in Studio 8 here.

I tried setting this up with an existing project, and I get the following error when I try to create a JPA statement:

[2019-02-24 18:55:51] Exception Description: Predeployment of PersistenceUnit [peer] failed.
[2019-02-24 18:55:51] Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.7.3.1-cuba): org.eclipse.persistence.exceptions.ValidationException
[2019-02-24 18:55:51] Exception Description: [class com.test.peer.entity.Person] uses a non-entity [class com.haulmont.cuba.security.entity.User] as target entity in the relationship attribute [field user].
[2019-02-24 18:55:51] java.lang.RuntimeException: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.7.3.1-cuba): org.eclipse.persistence.exceptions.ValidationException
[2019-02-24 18:55:51] Exception Description: [class com.test.peer.entity.Person] uses a non-entity [class com.haulmont.cuba.security.entity.User] as target entity in the relationship attribute [field user].
[2019-02-24 18:55:51] 	at org.eclipse.persistence.exceptions.ValidationException.nonEntityTargetInRelationship(ValidationException.java:1383)
[2019-02-24 18:55:51] 	at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.RelationshipAccessor.getReferenceDescriptor(RelationshipAccessor.java:569)
[2019-02-24 18:55:51] 	at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ObjectAccessor.processForeignKeyRelationship(ObjectAccessor.java:678)
[2019-02-24 18:55:51] 	at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ObjectAccessor.processOwningMappingKeys(ObjectAccessor.java:752)
[2019-02-24 18:55:51] 	at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ManyToOneAccessor.process(ManyToOneAccessor.java:130)
[2019-02-24 18:55:51] 	at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processOwningRelationshipAccessors(MetadataProject.java:1666)
[2019-02-24 18:55:51] 	at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage3(MetadataProject.java:1919)
[2019-02-24 18:55:51] 	at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:584)
[2019-02-24 18:55:51] 	at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:629)
[2019-02-24 18:55:51] 	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:2001)
[2019-02-24 18:55:51] 	at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:104)
[2019-02-24 18:55:51] 	at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:107)
[2019-02-24 18:55:51] 	at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:191)
[2019-02-24 18:55:51] 	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
[2019-02-24 18:55:51] 	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
[2019-02-24 18:55:51] 	at com.intellij.jpa.remote.impl.JpaFacadeImpl.createEntityManagerFactory(JpaFacadeImpl.java:17)
[2019-02-24 18:55:51] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2019-02-24 18:55:51] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[2019-02-24 18:55:51] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[2019-02-24 18:55:51] 	at java.lang.reflect.Method.invoke(Method.java:498)
[2019-02-24 18:55:51] 	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
[2019-02-24 18:55:51] 	at sun.rmi.transport.Transport$1.run(Transport.java:200)
[2019-02-24 18:55:51] 	at sun.rmi.transport.Transport$1.run(Transport.java:197)
[2019-02-24 18:55:51] 	at java.security.AccessController.doPrivileged(Native Method)
[2019-02-24 18:55:51] 	at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
[2019-02-24 18:55:51] 	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
[2019-02-24 18:55:51] 	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
[2019-02-24 18:55:51] 	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
[2019-02-24 18:55:51] 	at java.security.AccessController.doPrivileged(Native Method)
[2019-02-24 18:55:51] 	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
[2019-02-24 18:55:51] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[2019-02-24 18:55:51] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[2019-02-24 18:55:51] 	at java.lang.Thread.run(Thread.java:745) (no stack trace)

I have a Person entity which I have linked to the User entity through a many-to-one link. The problem might be because I haven’t referenced the persistence.xml file that contains the security definitions (that’s a guess).

Hi Ray!

Have you choosen CUBA EclipseLink as JPA provider in your JPA facets?

And what version of CUBA Platform do you use?
JPA support available on 7.1+ only.

Hi there.

Yes, I’ve included EclipseLink in the facet definition.

How many persistence xml files should I set up? I have set up just one which seems to have pulled in details for the system database tables.

Using 7.1 nightly build.

7.1 for CUBA Platform version too (Now it is available only as SNAPSHOT)? You can check the version in build.gradle or in CUBA Project proeprties dialog (CUBA -> Project Properties -> Platform version).

Ah! Right I haven’t done that. I’ll give it a try.

Also, there is an issue in IntelliJ IDEA Ultimate: https://youtrack.jetbrains.com/issue/IDEA-163803

You can upvote it if you need auto completion for entities with $ symbol in names.

Hi, I am trying jpa console. On query where entity has $ separator work, for example :
select e from sec$User e

Instead using my entities where name has underscore from example :
select p from prova1_Prodotto p

doesn’t work: the error say PROVA1_PRODOTTO is not valid object.

Any idea ?

Can’t say for sure without seeing the code. What is prova1_Prodotto? It should be the entity name given in the JPA entity class.

@Entity(name = “prova1_Prodotto”)

Afraid I can’t be much help; I’ve found the JPA console a little bit flaky.

Yes prova1_Prodotto is Entity name