I am getting the subject error when referencing the DataManager type within an entity class. I have an entity class ‘ActShips’ which is a standard entity defined through Cuba Studio with an embedded entity ‘status’. I have added a datamanager reference identically to how I have successfully added it in a servicebean but within the entity class, I get the subject error against the following line:
@Inject
private DataManager dataManager;
Are there particular limits to the use or syntax to DataManager within an entity or should it be called and behave identically to when used within a service?
I was able to remove the subject error (as the entity is persistent and DataManager shouldn’t be). It never really recognizes the datamanager and can’t do any operations with it so the entity must really be considered part of the Database tier.
Will just figure out a different way past my original problem, which was a standard but very slippery “Cannot get unfetched attribute [] from detached object” error using the ‘this’ member of the entity. I say standard because it is an error I have had and fixed in many other areas and I say slippery because in this case, I can’t find the problem view (or fix). Will post separately if it continues to be a problem.
You can use @Inject only in managed beans (services are also beans) and screen controllers. Entities are not managed by Spring container. However, you can use beans in entity methods via AppBeans class, for example:
Consider also moving the business logic out of your entity classes to managed beans. You can create managed beans in your global module so they will be available both on the client and middle tiers.