Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Jonathan Franchesco Torres Baca
    @jofrantoba
    how the id is a char. The solution is to place the trim function
    Thank you @andyjefferson
    Jonathan Franchesco Torres Baca
    @jofrantoba
    Hi @andyjefferson.
    If my primary key is a char. How can I avoid having to send the blank characters?
    log.info(dao.findEntity("2 "));
    @Override
    public T findEntity(Object id)throws UnknownException{
    PersistenceManager pm = null;
    try {
    PersistenceManagerFactory pmf = PMF.getClassPMF().getPMFStatic();
    pm = pmf.getPersistenceManager();
    return pm.detachCopy(pm.getObjectById(clazz, id));
    } catch (Exception ex) {
    UnknownException ue = new UnknownException(ex.getClass(), ex.getMessage(), ex.getCause(), true, true);
    ue.setStackTrace(ex.getStackTrace());
    ue.traceLog(false);
    throw ue;
    } finally {
    try {
    if (pm != null && !pm.isClosed()) {
    pm.close();
    }
    } catch (Exception ex) {
    UnknownException ue = new UnknownException(ex.getClass(), ex.getMessage(), ex.getCause(), true, true);
    ue.setStackTrace(ex.getStackTrace());
    ue.traceLog(false);
    throw ue;
    }
    }
    }
    Andy Jefferson
    @andyjefferson
    Only you know what sql is being used (the log), so only you can answer that question.
    Jonathan Franchesco Torres Baca
    @jofrantoba
    ok
    thank you!
    Jonathan Franchesco Torres Baca
    @jofrantoba
    Hi
    Jonathan Franchesco Torres Baca
    @jofrantoba
    help me please
    query = pm.newQuery(strJdoql.toString());
    strJdoql is
    UPDATE com.develtrex.softcommerce.app.model.entity.BeanAduana SET descripcion='hawai de vacaciones',estado='A',fechaInsert=Tue Oct 20 13:02:45 COT 2020 WHERE idAduana=='10'
    how is format date?
    now i am passing java.util.date
    Andy Jefferson
    @andyjefferson
    Dumping SQL of that nature into your RDBMS wouldn't work would it ? So dont do it with JDO.
    You can easily put a parameter in the JDOQL, and then pass in a java.util.Date as the parameter value.
    Jonathan Franchesco Torres Baca
    @jofrantoba
    thank you
    Andy Jefferson
    @andyjefferson
    But the LOG tells you what SQL is invoked so just look at it
    Jonathan Franchesco Torres Baca
    @jofrantoba
    @Test
    void updateBulk(){
    try {
    DaoAduana dao = new DaoAduana();
    log.info("Cantidad de actualizados: "+dao.updateBulk("descripcion='hawai de vacaciones',estado='A' ","idAduana=='15'",null));
    java.util.Date uDate=new java.util.Date();
    Object[] valueParam={uDate};
    log.info("Cantidad de actualizados: "+dao.updateBulk("descripcion='hawai de vacaciones',estado='A',fechaInsert=paramInsert", "idAduana=='10' PARAMETERS java.util.Date paramInsert",valueParam));
    } catch (UnknownException ex) {
    UnknownException ue = new UnknownException(ex.getClass(), ex.getMessage(), ex.getCause(), true, true);
    ue.setStackTrace(ex.getStackTrace());
    ue.traceLog(false);
    }
    }
    is already working
    @Override
    public Long updateBulk(String fieldsValuesUpdate,String filter,Object[] valuesParam)throws UnknownException {
    Transaction tx = null;
    Query query = null;
    PersistenceManager pm = null;
    try {
    PersistenceManagerFactory pmf = PMF.getClassPMF().getPMFStatic();
    pm = pmf.getPersistenceManager();
    tx = pm.currentTransaction();
    tx.begin();
    StringBuilder strJdoql = new StringBuilder();
    strJdoql.append("UPDATE").append(" ");
    strJdoql.append(clazz.getCanonicalName()).append(" ").append("SET").append(" ");
    strJdoql.append(fieldsValuesUpdate).append(" ");
    strJdoql.append("WHERE").append(" ");
    strJdoql.append(filter);
    query = pm.newQuery(strJdoql.toString());
    if(valuesParam!=null){
    return (Long) query.executeWithArray(valuesParam);
    }
    return (Long) query.execute();
    } catch (Exception ex) {
    rollback(pm, tx, query);
    throw throwsException(ex, false);
    } finally {
    try {
    commit(pm, tx, query);
    } catch (Exception ex) {
    rollback(pm, tx, query);
    throw throwsException(ex, false);
    }
    }
    }
    Jonathan Franchesco Torres Baca
    @jofrantoba
    hi
    I'm using mongo db
    i need to sample connection with jdo
    Jonathan Franchesco Torres Baca
    @jofrantoba
    image.png
    [08/12/2020 17:23:31:858][DEBUG][DataNucleus.Datastore] - Creating StoreManager for datastore
    [08/12/2020 17:23:31:886][DEBUG][DataNucleus.Connection] - Creando un pool de connecciones a la base de datos "indiant" en 1 servidores (localhost:27017)
    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
    [08/12/2020 17:23:32:725][ERROR][DataNucleus.Datastore] - Exception thrown creating StoreManager : org.slf4j.impl.StaticLoggerBinder
    Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.049 s <<< FAILURE! - in com.jofrantoba.model.jdo.daoentity.TestAbstractJdoDao
    com.jofrantoba.model.jdo.daoentity.TestAbstractJdoDao.hyperSqlMemConnection Time elapsed: 1.247 s <<< ERROR!
    java.lang.ExceptionInInitializerError
    at com.jofrantoba.model.jdo.daoentity.TestAbstractJdoDao.hyperSqlMemConnection(TestAbstractJdoDao.java:47)
    Caused by: javax.jdo.JDOFatalInternalException: Error creating transactional connection factory
    at com.jofrantoba.model.jdo.daoentity.TestAbstractJdoDao.hyperSqlMemConnection(TestAbstractJdoDao.java:47)
    Caused by: java.lang.reflect.InvocationTargetException
    at com.jofrantoba.model.jdo.daoentity.TestAbstractJdoDao.hyperSqlMemConnection(TestAbstractJdoDao.java:47)
    Caused by: java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
    at com.jofrantoba.model.jdo.daoentity.TestAbstractJdoDao.hyperSqlMemConnection(TestAbstractJdoDao.java:47)
    Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
    at com.jofrantoba.model.jdo.daoentity.TestAbstractJdoDao.hyperSqlMemConnection(TestAbstractJdoDao.java:47)
    Andy Jefferson
    @andyjefferson
    Why don't you put SLF4J in the classpath? That's what the exception says ...
    Jonathan Franchesco Torres Baca
    @jofrantoba
    it's working
    thank you
    image.png
    i add this libs
    Jonathan Franchesco Torres Baca
    @jofrantoba
    hi
    In MongoDB
    how can i use datanucleus with mongdb?
    this property isn't working
    props.setProperty("datanucleus.schema.autoCreateAll", "true");
    any example
    Andy Jefferson
    @andyjefferson
    Datanucleus tutorial works ...
    Jonathan Franchesco Torres Baca
    @jofrantoba
    [10/12/2020 15:50:24:862][DEBUG][DataNucleus.MetaData] - Clase "com.jofrantoba.model.jdo.daoentity.Aduana" : Inicializando Meta-Data
    [main] INFO org.mongodb.driver.connection - Opened connection [connectionId{localValue:2, serverValue:45}] to localhost:27017
    [10/12/2020 15:50:24:907][DEBUG][DataNucleus.Datastore.Schema] - Creando el esquema para la clase "com.jofrantoba.model.jdo.daoentity.Aduana" en la colleccion "Aduana"
    [10/12/2020 15:50:24:961][DEBUG][DataNucleus.Datastore.Schema] - Averiguando el indice "Aduana_PK" para la colleccion "Aduana" como "{"idAduana": 1}"
    [10/12/2020 15:50:24:975][DEBUG][DataNucleus.Connection] - ManagedConnection VA A COMMIT : "org.datanucleus.store.mongodb.ConnectionFactoryImpl$ManagedConnectionImpl@1601e47 [conn=com.mongodb.DB@3bffddff, commitOnRelease=true, closeOnRelease=true, closeOnTxnEnd=false]"
    [10/12/2020 15:50:24:975][DEBUG][DataNucleus.Connection] - ManagedConnection CERRADO : "org.datanucleus.store.mongodb.ConnectionFactoryImpl$ManagedConnectionImpl@1601e47 [conn=com.mongodb.DB@3bffddff, commitOnRelease=true, closeOnRelease=true, closeOnTxnEnd=false]"
    Tests run: 3, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.337 s <<< FAILURE! - in com.jofrantoba.model.jdo.daoentity.TestAbstractJdoDao
    com.jofrantoba.model.jdo.daoentity.TestAbstractJdoDao.createEntity Time elapsed: 0.021 s <<< ERROR!
    com.jofrantoba.model.jdo.shared.UnknownException: La clase "com.jofrantoba.model.jdo.daoentity.Aduana" no es s epuede hacer persistente. Esto significa que no esta analizada, o que la version analizada no esta en el CLASSPATH (o antes se encuentra una version que no esta analizada), o que el Meta-Data/Annotaciones de la clase no existe o no se encuentra disponible.
    at com.jofrantoba.model.jdo.daoentity.TestAbstractJdoDao.createEntity(TestAbstractJdoDao.java:75)
    Caused by: org.datanucleus.exceptions.ClassNotPersistableException: La clase "com.jofrantoba.model.jdo.daoentity.Aduana" no es s epuede hacer persistente. Esto significa que no esta analizada, o que la version analizada no esta en el CLASSPATH (o antes se encuentra una version que no esta analizada), o que el Meta-Data/Annotaciones de la clase no existe o no se encuentra disponible.
    at com.jofrantoba.model.jdo.daoentity.TestAbstractJdoDao.createEntity(TestAbstractJdoDao.java:75)
    image.png
    I'm using package test
    Jonathan Franchesco Torres Baca
    @jofrantoba
    putting the entity in the source package if it works
    Jonathan Franchesco Torres Baca
    @jofrantoba
    mvn enhance isn't working in test package
    image.png
    <plugin>
    <groupId>org.datanucleus</groupId>
    <artifactId>datanucleus-maven-plugin</artifactId>
    <version>5.2.1</version>
    <configuration>
    <log4jConfiguration>${basedir}/src/main/resources/log4j2.xml</log4jConfiguration>
    <verbose>true</verbose>
    </configuration>
    <executions>
    <execution>
    <phase>process-classes</phase>
    <goals>
    <goal>enhance</goal>
    </goals>
    </execution>
    <execution>
    <id>process-test-classes</id>
    <phase>process-test-classes</phase>
    <goals>
    <goal>enhance</goal>
    </goals>
    <configuration>
    <metadataDirectory>${project.build.testOutputDirectory}</metadataDirectory>
    </configuration>
    </execution>
    </executions>
    </plugin>
    execute datanucleus:enhance
    does not recognize the entity in the test package
    Andy Jefferson
    @andyjefferson
    This is ultimately down to Maven, not DataNucleus, and you could use "mvn --debug" to work things out. A long time ago someone contributed a "test-enhance" goal, as per datanucleus/datanucleus-maven-plugin#7 You could look at that. Maybe they didnt provide documentation for it? But I don't use it so its down to people to provide documentation updates if they want it