Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Alex Ilyin
    @engilyin
    Thank you Andy!
    Thirumurthi S
    @thirumurthis
    Hi All,
    I am working on an application which uses JDO and DataNucleus to query the Oracle database. The application was developed using Datanucleus 2.1.0 and now i am using 5.2.1, the application is fetching the data for most of the cases.
    There was one specific mapping which i am seeing "Exception in thread "main" java.lang.NoSuchMethodError: com.package.dao.car.dnSetValue" where the Java/Pojo mapping has package.jdo defeined for a table and corresponding java class extends
    another class which has defeined the field name. The enchancer successfully executed. https://stackoverflow.com/questions/58273407/jdo-table-mapping-to-pojo-with-no-annotation-and-extending-a-class-for-proper
    Andy Jefferson
    @andyjefferson
    @thirumurthis If the enhancer successfully executed then you can easily decompile the classes and inspect them for methods etc, as per http://www.datanucleus.org:15080/products/accessplatform_5_2/jdo/enhancer.html#_decompilation This would reveal whether it did indeed ... as would the log which tells you about addition of methods and fields to classes during the enhancement process
    Thirumurthi S
    @thirumurthis

    @andyjefferson I decompiled the class with 'javap -c', I could see the getValue and setValue method.
    Also the notice the comments for dnGet/Set as well
    30: invokevirtual #408 // Method dnGetValue:()Ljava/lang/String;
    33: invokevirtual #390 // Method dnSetValue:(Ljava/lang/String;)V

    Debugged and noticed the AbstractClassMetaData.class, getManagedMembers () returns 2 FieldMetadata and 1 PropertiesMetaData (corresponds to the field tagged using <property> tag in jdo) for this case.
    could there be any difference in using the Field and Properties in jdo mapping with respect to latest version of datanucleus.

    Andy Jefferson
    @andyjefferson
    @thirumurthis I personally use just field, always. Others use just properties. We have some tests with mixed, and all work (though nobody has ever convinced me of the point of doing that). What happened in some ancient version is of little interest because nobody here will look at old versions, far better to concentrate your time looking at WHY. The only time I'd see any possible problem is when a getter or a setter is missing ... i.e only one specified at some inheritance level. A runtime NoSuchMethod together with the decompiled classes should be enough to tell you what class is missing what.
    Andy Jefferson
    @andyjefferson
    Or maybe you have this situation ... datanucleus/datanucleus-core#257 If so, you just provide the other method and relay it to the superclass (or contribute a fix to the DN code ... as the issue says).
    Thirumurthi S
    @thirumurthis
    i think i found the root cause of my issue, the older DataNucleus-enhancer expects the getter/setter as jdoGetXXX/ jdoSetXXX which in newer version it should be dnGet/dnSet. The decompiler input helped since i compared the older and newer one locally. now it is working in my case. @andyjefferson Appreciate your help/support/time. Thank you.
    M W
    @ePortfel_gitlab
    I have a question. My JPA object has obj.dnStateManager.dirty=false and obj.dnStateManager.myLC.isDirty=true. In that case: is it dirty or not? And I also would propose to add the function NucleusJPAHelper.isDirty(obj) - it would be helpful, especially for debugging purposes.
    M W
    @ePortfel_gitlab
    My problem is that I have dirty object and in the same transaction I try to read different, unrelated object from database by JPAQuery.getResultList(). It flushes the dirty object and goes to StateManagerImpl.flush(). On StateManagerImpl:5844 it invokes clearDirtyFlags(). This function clears obj.dnStateManager.dirty and obj.dnStateManager.dirtyFields[] but does not touch obj.dnStateManager.myLC so obj.myPC.dnIsDirty() returns true which might be wrong cause the object is clean. As I am not sure what is going on here, is there something i miss?
    M W
    @ePortfel_gitlab
    Ok, I am learning so try to answer myself: obj.dnStateManager.dirty=false means all fields in obj are updated in database, but it does not mean that lifecycle od obj is not DIRTY. obj.dnStateManager.myLC.isDirty shows if the lifecycle state of obj is DIRTY which is another thing. So it is not inconsistent to have different values in the fields. But it is inconsistent if obj.dnStateManager.dirty=true and obj.dnStateManager.dirtyFields[] is false for every field. And that is the state I got.
    Andy Jefferson
    @andyjefferson
    If you want some function added then get the code and provide a Pull Request, simple. If you get some fields and overall object in some (strange) state, then define HOW by way of a reproduceable test. Obviously you also need to check on whether any surrogate fields are not dirty for that state to be considered strange.
    M W
    @ePortfel_gitlab
    So, there is the source of my problem. I have taken obj that is persistent and transactional. It has no dirty fields. And I invoked obj=entityManager.merge(obj). As the object is persistent and current values are in database I believe merge function should do nothing and give back reference to obj. But instead it goes like this: at org.datanucleus.state.StateManagerImpl.makePersistent(StateManagerImpl.java:4519) at org.datanucleus.ExecutionContextImpl.persistObjectInternal(ExecutionContextImpl.java:2085) at org.datanucleus.ExecutionContextImpl.persistObjectWork(ExecutionContextImpl.java:1869) at org.datanucleus.ExecutionContextImpl.persistObject(ExecutionContextImpl.java:1724) at org.datanucleus.api.jpa.JPAEntityManager.merge(JPAEntityManager.java:695) and on StateManagerImpl.java:4519 it makes obj.dnStateManager.dirty=true which seems to be wrong as no fields are dirty.
    Juan Cruz Gardey
    @juancruzgardey
    Hi everyone! I'm following the example presented in the documentation (that with inventories and products) and I observed that the query "SELECT this.name FROM mydomain.Product WHERE inv.products.contains(this) AND inv.name == 'Sale' VARIABLES mydomain.Inventory inv" does not work in mongo and Cassandra (it returns an empty collection) but it does in a mysql database. It seems that some datastores don't allow to filter by a field of a variable. Am I right? in that case, how do you solve that kind of queries? Thanks in advance!
    Andy Jefferson
    @andyjefferson
    Correct. For Cassandra, generation of a CQL query from JDOQL/JPQL is done in https://github.com/datanucleus/datanucleus-cassandra/blob/master/src/main/java/org/datanucleus/store/cassandra/query/QueryToCQLMapper.java and the method processVariableExpression() is not implemented. For MongoDB, generation of a Mongo query from JDOQL/JPQL is performed by https://github.com/datanucleus/datanucleus-mongodb/blob/master/src/main/java/org/datanucleus/store/mongodb/query/QueryToMongoDBMapper.java and the method processVariable() is not implemented. Being open source, people could contribute to the code, since that is why we made it public ...
    The log will always display what query is invoked (if the datastore supports a text-based query, such as CQL). So you can see what is being tried. If you think you can come up with a valid CQL, you could always put that in directly, and start an issue on how to support a specific variable for a particular datastore.
    Juan Cruz Gardey
    @juancruzgardey
    I have configured two persistence manager factories, one with mysql and the other one with xml. I'm trying to migrate the data from the mysql database to the xml by persisting the root object of my model but as a result I get a lot of "[Fatal Error] database.xml:3:1: Premature end of file." even when I have database.xml initialised, and at the end the file is empty (only with the xml header). The weird thing is that during the execution, I can see that some objects are being persisted in the file but then they are completely removed. Is it something related to cascade persisting? in my pom.xml, in addition to the dataNucleus-xml, jaxb-api and jaxb-impl jars I had to include also jaxb-core due to a missing class. Thanks!
    Juan Cruz Gardey
    @juancruzgardey
    I understand that the object that I'm trying to persist is transient because although I use detachCopy to decouple it from the source repository, it isn't detachable
    Andy Jefferson
    @andyjefferson
    If you have an object that you are trying to PERSIST into an XML datastore then why not just focus on that one operation ... create a transient object and pass it to makePersistent for the XML PersistenceManager? (and cut out the MySQL database for now).
    Juan Cruz Gardey
    @juancruzgardey
    @andyjefferson I also tried to persist a created object but when I use makePersistent on a new object that has associated another transient object, I get "java.lang.NullPointerException at com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.getIdValue" which I don't understand because I'm using application-identity ids with "uuid-hex" strategy. The persistence works well when I call makePersistent for the two objects separately.
    Andy Jefferson
    @andyjefferson
    @juancruzgardey Which is where you get the code for the XML plugin and debug it / extend it. That plugin was written a long time ago by someone else. Maybe they didnt provide support for all situations ...
    Andy Jefferson
    @andyjefferson
    For example, if your problem is relation persistence when using value generators on the related object, then maybe you need to ensure the id of the related object is set BEFORE the call to marshall(). Look at the other "store" plugins for what they do.
    Andy Jefferson
    @andyjefferson
    Juan Cruz Gardey
    @juancruzgardey
    Thanks @andyjefferson
    Kang
    @zhoukangcn
    Hello, when debug Hive (which use Datanucleus ), I found sqls like this (SET SQL_SELECT_LIMIT=1; SET sql_mode='STRICT_TRANS_TABLES') will send to MySQL.
    I could not find this sql in source code (Hive and Datanucleus).
    So, in which situation, sqls above wil send to MySQL ?
    Thanks
    Andy Jefferson
    @andyjefferson
    That will be the MySQL JDBC driver, not DataNucleus. Better ask them, or look at what happens in the DataNucleus log just before/after that call.
    Kang
    @zhoukangcn
    Thank you @andyjefferson
    abhishek bhutra
    @abskb_twitter
    Hey... can anyone point me to a working example to call stored procedure using datanucleous
    in 3.1 it was working fine.. I just updated to 3.5.1 and it failed
    Andy Jefferson
    @andyjefferson
    No idea what is "3.1" or "3.5.1".
    rickz21
    @rickz21

    I am using datanucleus 5.2.1, JDO 3.2, Java 11
    From the command line I see
    MariaDB [(none)]> status;
    mysql Ver 15.1 Distrib 5.5.65-MariaDB, for Linux (x86_64)
    My question is which MariaDB Connector/J version should I be using?
    If I use mariadb-java-client-2.3.0.jar, then the connection is successful.
    But, if I use mariadb-java-client-2.7.0.jar or 2.6.2 or 2.5.4 or 2.4.4 , then the connection fails.
    In the logs;
    WARN [DataNucleus.Datastore] - No Database Adapter was found for your JDBC driver specified. Faling back to the generic DatabaseAdapter!
    ...
    INFO [DataNucleus.General] - Error in initialisation of RDBMSStoreManager
    The java type java.lang.Integer (jdbc-type="", sql-type="") cant be mapped for this datastore. No mapping is available.
    org.datanucleus.exceptions.NucleusException: The java type java.lang.Integer (jdbc-type="", sql-type="") cant be mapped for this datastore. No mapping is available.
    at org.datanucleus.store.rdbms.adapter.BaseDatastoreAdapter.getColumnMappingClass(BaseDatastoreAdapter.java:2291)
    ...
    ERROR [DataNucleus.Datastore] - Exception thrown creating StoreManager : The java type java.lang.Integer (jdbc-type="", sql-type="") cant be mapped for this datastore. No mapping is available.

    Am I doing something wrong?
    Why won't the newer versions of MariaDB Connector/J work?

    Andy Jefferson
    @andyjefferson
    Why not post what your connectionURL us as a starter?
    rickz21
    @rickz21
    Here is my code.
    Properties dNprops = new Properties();   
    dNprops.setProperty("javax.jdo.PersistenceManagerFactoryClass", "org.datanucleus.api.jdo.JDOPersistenceManagerFactory");
    dNprops.setProperty("javax.jdo.option.ConnectionURL", "jdbc:mariadb://localhost:3306/test14);
    dNprops.setProperty("javax.jdo.option.ConnectionDriverName", "org.mariadb.jdbc.Driver");
    dNprops.setProperty("javax.jdo.option.ConnectionUserName", "root");
    dNprops.setProperty("javax.jdo.option.ConnectionPassword", "");
    dNprops.setProperty("javax.jdo.option.Mapping", "mysql");
    dNprops.setProperty("datanucleus.schema.autoCreateAll", "true");
    pmf = JDOHelper.getPersistenceManagerFactory(dNprops);
    Andy Jefferson
    @andyjefferson
    Then say why youre not using the latest versions if DN jars
    Andy Jefferson
    @andyjefferson
    E.g datanucleus-rdbms is at v5.2.4. To benefit from all recent changes you need latest code. MariaDB developers changed their URL in later versions of the jdbc driver (to use "mariadb" rather than "mysql") IIRC
    rickz21
    @rickz21
    I now have datanucleus 5.2.4 and
    Datastore Driver : name="MariaDB Connector/J" version="2.7.0"
    Everything works! Thank you very much, Andy.
    Krishna Prasad
    @krishnakittu
    hi
    how to read the current value stored in the sequence table
    i have a strategy defined as valueStrategy = IdGeneratorStrategy.INCREMENT
    it is creating a sequence_table
    how to read the value from the sequence table using JDO for an entity class
    Andy Jefferson
    @andyjefferson
    The "increment" value is automatically put into created objects, hence there should be no need to do that. If you really want to get the value from the table, issue an SQL query, https://www.datanucleus.org/products/accessplatform_5_2/jdo/query.html#sql
    Krishna Prasad
    @krishnakittu
    thanks @andyjefferson . i am showing in the ui to user what should be the next likely value in preview scenario..
    Your solution works for me. I will use the same..
    Dominik Zawadzki
    @dominoo911111_twitter
    Hi guys, I've a problem with mvn datanucleus:enhance , I get the error "Could not find or load main class org.datanucleus.enhancer.DataNucleusEnhancer"....What does mean ?
    Andy Jefferson
    @andyjefferson
    Not got datanucleus-core in the classpath perhaps, since the class mentioned is in that jar
    Dominik Zawadzki
    @dominoo911111_twitter
    thanks @andyjefferson so much, but if I've dependency (datanucleus-core) in my pom.xml it should be added automatically?
    Andy Jefferson
    @andyjefferson
    Well obviously it aint there when you execute "datanucleus:enhance", aka the scope. 'mvn --debug' tells you all you need to know, and is a general purpose way of debugging any maven classpath problems
    Dominik Zawadzki
    @dominoo911111_twitter
    ok, I see a bug in https://www.datanucleus.org/products/accessplatform_5_1/jpa/tools.html#maven scope as the runtime is wrong for datanucleus-core.
    Andy Jefferson
    @andyjefferson
    @dominoo911111_twitter If you 'see a bug' in something, kindly provide a pull request to the documentation in GitHub ( https://github.com/datanucleus/docs-accessplatform ). I personally cant see anything wrong but then i cant see your code and what you have needed to change, hence the pull request requirement. Thx
    Dominik Zawadzki
    @dominoo911111_twitter
    yes, sure!