java - Extending JPA entity mapping -
I'm exploring an easy way to expand the existing JPA mapping. This idea is as follows:
I have an ER project with the EJB3 + JPA module in which the class A is annotated and the table is mapped to class_a. But I want some other modules (another EJB module) that have classes, which increases the class to more assets (expand?).
In a way, though I want to add those extra fields to the class_a table and run a non-HQL query to retrieve that data. This is not good because I have to do a lot of things by hand: type mapping, column mapping etc.
I have done simple checks but it seems that I can not expand Class 1 in second module because they are not seen by different EntityManagerFactories and the first module is used by the other and vice versa
I have already seen & lt ;. Jar file & gt; I need something like this inside the persistence.xml, but to use it, the file should be listed in the first module and it should be present (if not found, it will not leave it). Is there anything that can be applied to the extended module (the second one) and not able to grow (first)?
If there is any way to expand JPA mapping in run-time, it is great. Is there any such way? Is there any other solution to my problem? The following solutions are as follows: I have a jar and two EJB modules:
Jar base is one It has base organizations and local interfaces for expansion:
@Entity Public Category BaseInty {public long id; @Id @GeneratedValue public long getId () {... ... other variables, ticker games, setters ...} @Local Public Interface EntitiyManagerWithExtendedEntitiesInterface {Public EntityManager getEntityManager; } The first EJB module is that it will expand the base institutions and add to add EJB as unit manager. Jar file & gt; ../ path_to_first_jar_file.jar & lt; / Jar file & gt; line
persistence.xmlwithcode included> @Entity ... discriminator comments public class ExtEntity BaseEntity {. .. Extra fields here} Extends the @Stateless Public Class EntitiyManagerWithExtendedEntitiesBean EntitiyManagerWithExtendedEntitiesInterface {@PersitenceContext EntityManager implements them; Public EntityManager getEntityManager () {Return them; }}interface)The second EJB module requires EJBs to compile only that the JAR, but to run (an EJB code that will require the code) EJB will be required> EntitiyManagerWithExtendedEntitiesInterface
@Stateless public class getSomeEntity {@EJB EntitiyManagerWithExtendedEntitiesInterface ext .; EntityManager them; @PostConstruct Public Zero InjectEntityManager () {em = ext.getEntityManager (); } Public Zero ejbInterfaceMethod () {... method is that they use variables (EntityManager)}}
Dependency to the application server in this way I have to manage the modules and I can easily swap 1 EJB module to include another set of extensions organizations.
Comments
Post a Comment