Re: Any way to configure "development" mode for DataNucleus to force it to reload class metadata?
ebenzacar@...
Thanks for the tip. I was looking for a `clearCache` or a `clearMetadata` method or something to that extent that I didn't notice the `unmanage/unload` methods. Eric |
|
Re: Any way to configure "development" mode for DataNucleus to force it to reload class metadata?
There is a MetaDataManager for each PMF. It loads metadata when it needs to. There is a method unloadMetaDataForClass to unload a class' metadata if needing to do so.
There is also a method on JDOPersistenceManagerFactory unmanageClass(String className) which will call the underlying MetaDataManager method as well as the associated StoreManager method. Added in DN 4.0. You could also ask on Apache ISIS support (which uses DataNucleus) because Dan Haywood played around with a JRebel addon to do something related some time ago. No idea if he published it. |
|
Any way to configure "development" mode for DataNucleus to force it to reload class metadata?
ebenzacar@...
I'm working on a fairly large, slow startup legacy application in which I am slowly trying to integrate DataNucleus. I am also leveraging JRebel, which allows me to modify most classes on the fly without having to restart the application everytime. For most business oriented logic, this works great. Eric |
|
Re: Migration from Kodo: Any way to make it store foreign keys to later get already loaded objects from cache (for performance)?
ebenzacar@...
Hi, I'm running into a similar problem as you where I need to create an ugly JDOHelper.getObjectIdAsLong() hack as well due to some legacy Kodo code.
|
|
Multitenancy query result error - query cache key (bug ?)
stephane <passignat@...>
Hi,
When 2 queries with the same tenant but different tenantReaders are executed, the second one returns the result of the first one. The SQL generated is the same for the second query while it should be different. The query cache key only uses the tenant which may explain the case. String multiTenancyId = ec.getNucleusContext().getMultiTenancyId(ec);(no test case yet) -- Stephane |
|
Re: Strange behaviour running in WIldfly 10 with EmulatedXAResource
You are using a JEE connection pool but are setting the resource type as "local" hence DN will try to commit the connection (since it commits local things). Your connection (JBoss JCA) then throws an exception because it wants to commit things, maybe?. Use a local connection if using local ? But then I don't use JEE containers ...
You also have "datanucleus.connectionPoolingType" yet have already specified "connectionFactoryName" to be from JBoss. Either DataNucleus creates the connections to the datastore or JBoss does, but you can't have both, clearly. |
|
Strange behaviour running in WIldfly 10 with EmulatedXAResource
ebenzacar@...
I'm encountering a strange behaviour for which I have not been able to pinpoint the cause and was hoping that someone could help point me in the right direction.
I have an application running under JBoss EAP 7.0 (Wildfly 10), but only having the datasource specified at the container level. I am trying to fully manage the JDOPersistenceFactory from within the JEE (EJB) application. My persistence.xml is configured as follows (located in my EJB jar in the META-INF/ folder: <persistence-unit name="cache" transaction-type="RESOURCE_LOCAL"> I have instantiated my connection factory statically as follows: public class DataNucleusPersistenceManagerFactory { All my Stateless EJBs are defined as BeanManagedTransactions by extending a base class with the following interceptor defined: @TransactionManagement(TransactionManagementType.BEAN) This allows for the logic for my bean method to simply use the pm within its logic without needing to worry about transaction boundaries/etc. I have simplified the interceptor for illustration purposes. My issue that I am encountering is when I have nested EJBs (ie: one EJB which calls another). In this context, I end up with nested transactions, since each EJB method call will create a new PM and manage its own transaction. When this happens, the inner transaction completes successfully, but the outer one throws and exception that: Caused by: java.sql.SQLException: IJ031019: You cannot commit during a managed transaction
at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManagedConnection.java:1063)
at org.jboss.jca.adapters.jdbc.WrappedConnection.commit(WrappedConnection.java:834)
at org.datanucleus.store.rdbms.ConnectionFactoryImpl$EmulatedXAResource.commit(ConnectionFactoryImpl.java:734)
at org.datanucleus.transaction.ResourcedTransaction.commit(ResourcedTransaction.java:348)
at org.datanucleus.transaction.ResourcedTransactionManager.commit(ResourcedTransactionManager.java:64)
at org.datanucleus.TransactionImpl.internalCommit(TransactionImpl.java:417)
at org.datanucleus.TransactionImpl.commit(TransactionImpl.java:288)
at org.datanucleus.api.jdo.JDOTransaction.commit(JDOTransaction.java:99)
... 128 more
Stepping through the code, falling into the IronJacamar libraries, I see that the ConnectionWrappers are treating this as an XA transaction. I also see that from the `org.datanucleus.store.rdbms.ConnectionFactoryImpl$EmulatedXAResource` resource which the DN CF creates. This is where I get confused. I'm not sure why this is happening, nor if this is "normal"/expected behaviour. I have tried to reproduce this in a small test application by embedding 2 txs, with the same PU defined, but it works properly there. I have not yet tried embedding two EJBs in a test application. I can only suspect that I have an errant configuration somewhere which is causing this, but cannot identify what. My Datasource is configured the same for my test application. Just for reference: <datasource jndi-name="java:jboss/datasources/DS" pool-name="DS" enabled="true"> What am I missing, doing wrong? Do I have a incorrect or missing configuration? What is DN / WF seeing this as an XA transaction? Or is this expected behaviour when working with nested EJBs due to the inherent stateless / pooling behaviour of EJBs? If the latter, am I forced to move to Container Managed Transactions such that no bean commits its own transaction? If not, how would I know which transaction is the outer transaction? Thanks for any insights. Eric |
|
Re: How to configured the PersistenceManager for Bean Managed Transactions?
https://www.datanucleus.org/products/accessplatform_5_2/jdo/persistence.html#jboss7 says that "DataNucleus JCA adapter supports both Local and XA transaction types".
|
|
Re: Proper configuration with the JCA connector in WIldfly
FYI The JCA was written by people who no longer develop DataNucleus, and is dependent on volunteers. Consequently you're pretty much on your own. Clearly JDO is just as usable outside of JCA, creating a PMF and PM's as required.
|
|
Re: How to configured the PersistenceManager for Bean Managed Transactions?
ebenzacar@...
As a followup question, does the JCA adapter support anything other than XATransactions? Eric |
|
How to configured the PersistenceManager for Bean Managed Transactions?
ebenzacar@...
I'm trying to integrate DN (JDO) into my JEE application via the JCA adapter, and configure the Persistence manager to understand BeanManagedTransactions. I am retrofitting this into existing code (formerly using Kodo), and am having difficulties getting the configuration correct.
In my `persistence.xml` file, I have defined my PU as follows: <persistence-unit name="pu">
<jta-data-source>java:jboss/datasources/POC_DN</jta-data-source>
<properties>
<property name="datanucleus.connection.resourceType" value="JTA"/>
<property name="datanucleus.transaction.type" value="JTA"/>
<property name="datanucleus.storeManagerType" value="rdbms"/>
<property name="datanucleus.schema.autoCreateAll" value="false"/>
<property name="datanucleus.ConnectionFactoryName" value="java:jboss/datasources/POC_DN"/>
<property name="datanucleus.connectionPoolingType" value="dbcp2-builtin"/>
<property name="javax.persistence.jta-data-source" value="java:jboss/datasources/POC_DN"/>
<property name="datanucleus.jtaLocator" value="jboss"/>
</properties>
</persistence-unit>
In my Bean code, I my bean is defined as a: @TransactionManagement(TransactionManagementType.BEAN) Finally, in my actual code, I am retrieving the persistence manager from the JNDI and getting the transaction from it (where jndiName is the name of my connection-definition defined in the container) PersistenceManagerFactory pmf = (PersistenceManagerFactory) context.lookup(jndiName);
pm = pmf.getPersistenceManager(); pm.currentTransaction.begin(); ... ... pm.currentTransaction.commit(); However, in doing so, I get error messages that I cannot begin a transaction that has already started. If I omit the begin(), then I get an error message that "IJ031019: You cannot commit during a managed transaction". In both circumstances, it is clear to me that the PM does not understand that I want to use BeanManagedTransactions. Is there a special configuration that I need to use? Is retrieving the PM from the JNDI explicitly like this causing my issues? How else can I access the Tx statically? Am I forced/required to retrieve the `java:jboss/UserTransaction` from the JNDI instead? Thanks for any insight/tips. Eric |
|
Proper configuration with the JCA connector in WIldfly
ebenzacar@...
I'm trying to integrate my instance of JBoss/Wildfly 10 with the Datanucleus JCA-JDO connector. I saw an original post for JBoss AS7 (https://developer.jboss.org/docs/DOC-17094) as linked from the DataNucleus docs, but I find it somewhat incomplete. I've been struggling with improving the configuration and will try to post a complete howto/installation once done.
At the moment, I am having trouble understanding how to define my JNDI datasource in my persistence unit. I have my DataSource properly defined in my Wildfly standalone.xml configuration: <subsystem xmlns="urn:jboss:domain:datasources:4.0"> I have the following configured in my persistence unit: <persistence-unit name="pu"> Finally, I have my rar configured as: <resource-adapter id="datanucleus-jca-jdo"> Now, in my Spring Java code, I am trying to retrieve the PMF via JNDI and retrieve a PersistenceManager in the following method: @Bean All these pieces work; I get a PM injected into my controller class: @RestController However, when it actually tries to execute the `getObjectById()` call, I get an exception thrown:
Eric |
|
Re: Any way to use JPA and JDO together easily?
ebenzacar@...
Thanks; I hadn't seen that extension.
I see that the the JDO pm allows for using JPQL but remaining within the JDO framework. Which from a consistency perspective is great. However, from a "retrofit" perspective, I still have the problem of my legacy code using all javax.persistence constructs and classes. But hopefully shouldn't be too bad - I see many of the javax.jdo.Query methods are analogous to the javax.persistence.Query methods. I will post as I continue the efforts if I have additional JPQL questions/issues. So far, a quick test has yielded great results. |
|
Multitenancy disabled doesn't work (probably a bug)
Hi,
The disable option doesn't work: @MultiTenant(disable = true) In the MultiTenantHandler DN looks for disabled instead of disable attribute name. And then the disable extension is added if it's not disabled Boolean disabled = (Boolean)annotationValues.get("disable");Suggestion: Boolean disabled = (Boolean)annotationValues.get("disable"); -- Stephane |
|
Re: Compilation error on ObjectExpression in generated Q class
Suggest that you work out what the Q class should be, get the code from here, and contribute an update.
|
|
Compilation error on ObjectExpression in generated Q class
mwhesse@...
I have a javax.validation.Min annotation on an Integer field in my JDO entity
@Column(allowsNull = "true")
@Min(0) @Getter @Setter
private Integer scale;
public final ObjectExpression<@javax.validation.constraints.Min(0L) java.lang.Integer> scale; |
|
Re: Any way to use JPA and JDO together easily?
Perhaps you would be better off looking at the DataNucleus (and JDO) documentation.
The JDO spec mandates being able to use JPA metadata (XML / annotations) with JDO persistence, and DataNucleus (JPA) also allows use of JDO metadata (XML / annotations) with JPA persistence. DataNucleus seemingly allows use of JPQL with the JDO API (without the need to create any EntityManagerFactory), though not sure what query needs JPQL for that JDOQL can't express. A query language like JPQL is in core code and hence available to both APIs. Kodo doesn't seem to be as flexible as that ;-) |
|
Any way to use JPA and JDO together easily?
ebenzacar@...
As I am migrating my legacy Kodo based application to DataNucleus, I noticed that the application uses both JDO for most persistence based interaction, however has several JPQL queries which leverage a JPA Entity Manager. The app leverages OpenJPA's `JPAFacadeHelper.toEntityManager()` to create a JPA entity manager from Kodo's persistence manager. My application exclusively uses a RDBMS store (MSSQL to be specific). Eric |
|
Re: Trouble understanding how to lookup objects that have a Datastore Identity by their PK (if the PK is not identified in the model)
ebenzacar@...
You could do something like
Eric |
|
Re: Trouble understanding how to lookup objects that have a Datastore Identity by their PK (if the PK is not identified in the model)
Use of implementation-specific classes is always a bad idea IMHO. Imagine hardcoding Kodo-specific stuff and then finding that you need to change provider some time later ...
In the same way, reliance on things outside the JDO spec can be problematic. You could do something like MyClass myObj = pm.getObjectById(MyClass.class, theIdValue);This would likely work whether you are using (single-field) application identity OR datastore identity. And you don't need to cast anything ... I did add an enhancement to datanucleus-core for datastore-id newObjectId, so whether it needs that only you can find out |
|