New entity ASSOCIATION attribute is always transient with the checkbox selected and grayed out

I am adding an ASSOCIATION attribute to a new table in IntelliJ. The CUBA plugin version is 12.1-191.

The New Attribute dialog shows and I enter the attribute name, select the attribute type of ASSOCIATION and select my referenced entity. The New Attribute dialog always shows with the Transient checkbox grayed out and selected. I checked the entity .java and can confirm that @Transient has been added to the attribute. I tried removing @Transient and using the designer again adds the @Transient back into the entity .java file.

If I create new Master/Detail entities that both use the StandardEntity class, then the @Transient checkbox is not selected and editable.

The table I am creating and adding the attribute for is a parent of type BaseIntIdentityIdEntity as these were imported into my model from a legacy system with integer primary keys. The database is MSSql 2014.

I created a new project and have no trouble with any types of Master/Detail using the New Attribute dialog with different mixes of the class the entity inherits from.

Luckily if I avoid the entity designer, then I can hand-code my attributes and this seems to be working so far, but obviously the designer is easier for code-generation.

I also downloaded CUBA Studio to see if that made a difference and it didn’t.

Other than the inherited classes being different, the only other obvious difference I can see is that my master table I am referring to in the new attribute has: -

@DesignSupport("{'imported':true}")
@AttributeOverrides({
        @AttributeOverride(name = "id", column = @Column(name = "FishLotRearingUnitHistoryDataID"))
})

Mike.

Here’s a screenshot of the New Attribute dialog with the Transient checkbox selected and disabled.

51%20PM

Hi @mwhy,
I see @DesignSupport("{'imported':true}") in your code.
It seems HMSRearingUnitHistoryData is in additional datastore and was created by the “Generate Model” tool in Studio.
If so, it is OK to create the attribute in such manner: link to an entity in additional datastore is presented by a @Transient attribute. And as an option Studio creates a persistent field to store the related entity id.
It should work OK.
Try to create the link in Entity Designer and it should show a message similar to the following one.

Regards.

Hi Rostislav - the entity HMSRearingUnitHistoryData is in the same datastore (and physical database) as the entity I am creating. HMSRearingUnitHistoryData was originally imported using the Generate Model tool. I have used the New CUBA entity/New Attribute screens many times in the past and for some reason the entity modeling screens seem to be behaving differently.

Do you think I should try removing @DesignSupport("{'imported':true}") from my entity HMSRearingUnitHistoryData.java file or will have that have adverse effects?

Mike.

There is definitely some odd behavior I am experiencing. I managed to manually create my new entity with the ASSOCIATION to HMSRearingUnitHistoryData. Now when I add a composition on HMSRearingUnitHistoryData to my new entity and assemble I receive the following error.

 > Configure project :
Not Java8. Loading java.xml.bind and org.glassfish.jaxb

> Task :app-global:compileJava
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Exception in thread "main" Local Exception Stack: 
Exception [EclipseLink-40007] (Eclipse Persistence Services - 2.7.3.6-cuba): org.eclipse.persistence.exceptions.StaticWeav
eException
Exception Description: An exception was thrown while weaving: [Ljava.lang.String;@6f10d5b6
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 
2.7.3.6-cuba): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [cuba] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.7.3.6-cuba): org.eclipse.persistence.ex
ceptions.ValidationException
Exception Description: [class gov.azgfd.fins.entity.hms.HmsRearingUnitHistoryData] uses a non-entity [class gov.azgfd.fins
.entity.hms.HmsRearingUnitHistoryDataFeedMortalities] as target entity in the relationship attribute [field feedMortalityL
og].
        at org.eclipse.persistence.exceptions.StaticWeaveException.exceptionPerformWeaving(StaticWeaveException.java:140)
        at org.eclipse.persistence.tools.weaving.jpa.CubaStaticWeave.main(CubaStaticWeave.java:37)
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.7.3.6-c
uba): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [cuba] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.7.3.6-cuba): org.eclipse.persistence.ex
ceptions.ValidationException
Exception Description: [class gov.azgfd.fins.entity.hms.HmsRearingUnitHistoryData] uses a non-entity [class gov.azgfd.fins
.entity.hms.HmsRearingUnitHistoryDataFeedMortalities] as target entity in the relationship attribute [field feedMortalityLog].
        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:2104)
        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:2080)
        at org.eclipse.persistence.tools.weaving.jpa.StaticWeaveClassTransformer.buildClassTransformers(StaticWeaveClassTransformer.java:128)
        at org.eclipse.persistence.tools.weaving.jpa.StaticWeaveClassTransformer.<init>(StaticWeaveClassTransformer.java:78)
        at org.eclipse.persistence.tools.weaving.jpa.StaticWeaveProcessor.process(StaticWeaveProcessor.java:252)
        at org.eclipse.persistence.tools.weaving.jpa.StaticWeaveProcessor.performWeaving(StaticWeaveProcessor.java:174)
        at org.eclipse.persistence.tools.weaving.jpa.StaticWeave.start(StaticWeave.java:117)
        at org.eclipse.persistence.tools.weaving.jpa.CubaStaticWeave.main(CubaStaticWeave.java:35)
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.7.3.6-cuba): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [cuba] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.7.3.6-cuba): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class gov.azgfd.fins.entity.hms.HmsRearingUnitHistoryData] uses a non-entity [class gov.azgfd.fins.entity.hms.HmsRearingUnitHistoryDataFeedMortalities] as target entity in the relationship attribute [field feedMortalityLog].
        at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:233)
        ... 8 more
Caused by: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.7.3.6-cuba): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class gov.azgfd.fins.entity.hms.HmsRearingUnitHistoryData] uses a non-entity [class gov.azgfd.fins.entity.hms.HmsRearingUnitHistoryDataFeedMortalities] as target entity in the relationship attribute [field feedMortalityLog].
        at org.eclipse.persistence.exceptions.ValidationException.nonEntityTargetInRelationship(ValidationException.java:1383)
        at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.RelationshipAccessor.getReferenceDescriptor(RelationshipAccessor.java:569)
        at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.RelationshipAccessor.getOwningMapping(RelationshipAccessor.java:485)
        at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.OneToManyAccessor.processOneToManyMapping(OneToManyAccessor.java:217)
        at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.OneToManyAccessor.process(OneToManyAccessor.java:150)
        at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processNonOwningRelationshipAccessors(MetadataProject.java:1652)
        at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage3(MetadataProject.java:1941)
        at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:584)
        at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:629)
        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:2001)
        ... 6 more

> Task :app-global:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app-global:compileJava'.
> Process 'command '/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s
7 actionable tasks: 1 executed, 6 up-to-date

When I view the COMPOSITION in the entity designer the type field is empty and my new entity does not appear in the list of entities to select from. The assemble error is from when I manually created the COMPOSITION attribute on HMSRearingUnitHistoryData as the designer won’t let me pick it.

44%20AM

Here’s a screenshot of an existing entity that I can successfully pick in the type field and the cardinality and other fields show correctly. For some reason my new entity with the ASSOCIATION to HMSRearingUnitHistoryData does not show in the Type dropdown. What are the rules for what entities appear in the Type dropdown? That may help me troubleshoot why my new entity doesn’t appear.

31%20AM

Any new entities I create e.g. a detail entity, a master entity and then create associations from detail to master and then add a composition from master to detail work perfectly. It’s just using entities imported using the data modeling tool that are the problem.

All of these entities are in the same datastore and physical database.

In the “Type” dropdown Designer shows only entities in the same data store. So I still think HMSRearingUnitHistoryData is in another.
Please, examine the contents of *persistence.xml files (separate file for each datastore). You can find them in the Global module. When both entities are in the same *persistence.xml Studio allows to link them with any type of relation.

I only have one persistence.xml file in the src folder, there are two others in my modules/global/bin and modules/global/bin/main.

My new entity did not exist in this file and when I manually added it, the Type dropdown does now show it and my build is now successful.

In my other reply I mentioned my other test master/detail tables that I created from scratch, are working perfectly. I did a global search for those entity names and I could not find them in any persistence.xml file at all.

When I click on the Data Model and create a new entity I enter the class name, select my package, select Entity Type - Persistence and an Id Type of UUID. After saving, the entity does not get added to my persistence.xml file.

Any idea why?

1 Like