Date   

Re: cascade-update not working in my case

pavansailendra04@...
 

Thanks Andy for the confirmation. Can we achieve the same the functionality through any other existing feature?


Re: cascade-update not working in my case

Andy
 

Maybe, since not a core JDO feature, nobody had time to implement it for 1-1 relations. Maybe there was no resource.


Re: cascade-update not working in my case

pavansailendra04@...
 

I have debugged and tried adding another field.
Class log
{
private int id;
@Persistent(column = "userId", defaultFetchGroup = "true")
@Extensions({@Extension(vendorName = "datanucleus", key = "cascade-update", value = "false")})
private User[] user;
}

Added user array instead of user. Now the casade-update seems to be working.
https://github.com/datanucleus/datanucleus-rdbms/blob/4.0/src/main/java/org/datanucleus/store/rdbms/mapping/java/ArrayMapping.java#L237
Any specific reason why it is not implemented for normal objects. Implemented for collections, maps and arrays only 


cascade-update not working in my case

pavansailendra04@...
 

Class log
{
private int id;
@Persistent(column = "userId", defaultFetchGroup = "true")
@Extensions({@Extension(vendorName = "datanucleus", key = "cascade-update", value = "false")})
private User user;
}


Class User {
@Persistent(primaryKey = "true", valueStrategy = IdGeneratorStrategy.IDENTITY)
private int userId;
}

Every log has related user.

When updating or inserting log, we dont want to update user properties .
For example

Log log = new Log();
user.setRegion("CA")
log.set(user);

persist(log);

User region is getting updated even if cascade-update is false. [Cascade-persist is working!!]

Can some one please help on this ?

I debugged the code https://github.com/datanucleus/datanucleus-rdbms/blob/0812934216a04a63e953e173ebf4398250cc8150/src/main/java/org/datanucleus/store/rdbms/mapping/java/PersistableMapping.java#L598 cascade persist check is there but could not find any check for cascade-update. Should we persist data in different way ?


Re: Custom Value Generator is not working in 5.2

ponssaran@...
 

Hi Andy,

Pull Request created for this bug.
https://github.com/datanucleus/datanucleus-core/pull/406


Re: Custom Value Generator is not working in 5.2

Andy
 

It will be available in GitHub when I have time to translate what you have changed into something applyable. It won't be "released" until the next release, and since the last one was not long ago, that means at least 3 months.


Re: Custom Value Generator is not working in 5.2

ponssaran@...
 

Hi Andy,

Will this be available in 5.2.x release?


Re: Custom Value Generator is not working in 5.2

ponssaran@...
 
Edited

Hi Andy,

I don't have access to github.com. I have attached the files modified for this fix. Verified with our product it is working as expected.

Modified files in 5.2 branch
AbstractStoreManager.java
ValueGenerationManagerImpl.java


Re: the multi-morph feature of JPQL is not support when using jdoAPI?

Andy
 
Edited

As i said, the JPA spec defines JPQL and it does NOT say that this query should work, nor does it use the term 'multi morph' anywhere.

DataNucleus allows JPQL to be used with JDO. But that query (candidate class using "subclass-table") is not supported like that, whether using JDOQL or JPQL. As also said, if you want that supported you need to contribute it


Re: the multi-morph feature of JPQL is not support when using jdoAPI?

WeiMing.Tang@...
 

Hi, Andy,   it works in a lot of cases but not this case.  And it is mentioned in the document https://www.datanucleus.org/products/accessplatform_5_2/jdo/query.html#jpql.  as a datanucleus extension.


Re: the multi-morph feature of JPQL is not support when using jdoAPI?

Andy
 

No, there is nothing in the JPA spec that says that.

If you want it then get the code and contribute it


Re: the multi-morph feature of JPQL is not support when using jdoAPI?

WeiMing.Tang@...
 

HI, Andy,  for using jdo api to do jpaql,    we have legacy project which has a lot of jdoql and jpql at the same time. In the past, we used KODO+open jpa at the same time, Now, when we change to datanucleue,  we don't want to maintan persistanceManger and entityManager at the same time any more. But we still want to use the existing JPQLs.
 


Re: the multi-morph feature of JPQL is not support when using jdoAPI?

WeiMing.Tang@...
 

Hi, Andy,  Thanks for answering.  What I expect is when I run "select t from izone.adams.model.messaging.SMSMessageAbstract t where t.creationDate>=:p_startDate ",  I should be able to get result without exception like  org.datanucleus.exceptions.NucleusUserException: Unable to find table for primary t.creationDate since the class izone.adams.model.messaging.SMSMessageAbstract is managed in multiple tables.  Look at the the exception, it concerns about how to handle multiple morph(return all kind of subclass object of SMSMessageAbstract ).


Re: Custom Value Generator is not working in 5.2

Andy
 

Right, so if that is important for you on 5.2 then please provide a Pull Request.


Re: the multi-morph feature of JPQL is not support when using jdoAPI?

Andy
 

Define what you mean by "multi-morph feature of JPQL"? Provision of JPQL within JDO provides features that DataNucleus core/rdbms provide, just as JPQL within JPA/Jakarta.

I can't say I ever see a need to use JPQL when using JDO; JDOQL provides for that query.


the multi-morph feature of JPQL is not support when using jdoAPI?

WeiMing.Tang@...
 

We have :
@PersistenceCapable
@Inheritance(strategy= InheritanceStrategy.SUBCLASS_TABLE)
@DatastoreIdentity(strategy= IdGeneratorStrategy.SEQUENCE, sequence="jdoid_seq", column="ID")
@Version(strategy=VersionStrategy.VERSION_NUMBER, column="VERSN")
public abstract class SMSMessageAbstract{
............


public class SMSMessage extends SMSMessageAbstract{
}

@PersistenceCapable(table="SMSMESSAGEPROCESSED")
@Inheritance(strategy= InheritanceStrategy.NEW_TABLE)
@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, column="TYP", indexed="true")
@DatastoreIdentity(strategy= IdGeneratorStrategy.SEQUENCE, sequence="jdoid_seq", column="ID")
@Version(strategy=VersionStrategy.VERSION_NUMBER, column="VERSN")
public class SMSMessageProcessed extends SMSMessageAbstract{
..........
}

When we execute:   select t from izone.adams.model.messaging.SMSMessageProcessed t where t.creationDate>=:p_startDate , we get expected result.
But when we execute:
select t from izone.adams.model.messaging.SMSMessageAbstract t where t.creationDate>=:p_startDate, 
we get exception:


org.datanucleus.exceptions.NucleusUserException: Unable to find table for primary t.creationDate since the class izone.adams.model.messaging.SMSMessageAbstract is managed in multiple tables.

When we execute the jpaql, we are using jdoapi, like:
Query query = pm.newQuery("JPQL", sql);
query.setNamedParameters(params);
List results = query.executeResultList(SmsMessageAbstract.class);  //Or SmsMessageProcessed.class, depening on the jpaql. 

Our question is:   According to the above code, seems  jpql  doesn't support multip-morph query when using jdoapi.  Is this an known problem or it is an unexpected bug?

Thanks a lot for any answering.





Re: Custom Value Generator is not working in 5.2

ponssaran@...
 

Hi Andy,

Thanks for the reply.
Following is the plugin.xml that we are using, it has unique=true.
<?xml version="1.0"?>
<plugin id="xyz" name="DataNucleus plug-ins" provider-name="XYZ">
<extension point="org.datanucleus.store_valuegenerator">
<valuegenerator name="XyzValueGenerator" class-name="com.xyz.datanucleus.util.XyzValueGenerator" unique="true"/>
</extension>
</plugin>
As I said earlier the same plugin.xml works fine in 5.0

After debugging, the link that you shared in the previous thread is where the bug is
In the Constructor of RDBMSStoreManager the AbstractStoreManger constructor is called
public RDBMSStoreManager(ClassLoaderResolver clr, PersistenceNucleusContext ctx, Map<String, Object> props)
{
super("rdbms", clr, ctx, props);

The AbstractStoreManger instantiates ValueGenerationManager before the nucleusContext is set in the constructor
protected ValueGenerationManager valueGenerationMgr = new ValueGenerationManagerImpl(this);

protected AbstractStoreManager(String key, ClassLoaderResolver clr, PersistenceNucleusContext nucleusContext, Map<String, Object> props) { this.storeManagerKey = key; this.nucleusContext = nucleusContext;

So in the constructor of ValueGenerationManagerImpl while loading the plugin there is always a NullPointerException (storeMgr.getNucleusContext() == null). Due to this the custom value generator is never added to uniqueGeneratorsByName map.
try
{
ConfigurationElement[] elems = storeMgr.getNucleusContext().getPluginManager().getConfigurationElementsForExtension("org.datanucleus.store_valuegenerator",
"unique", "true");
if (elems != null)
{
for (ConfigurationElement elem : elems)
{
// Assumed to not take any properties
generator = (ValueGenerator)storeMgr.getNucleusContext().getPluginManager().createExecutableExtension("org.datanucleus.store_valuegenerator",
new String[] {"name", "unique"}, new String[] {elem.getName(), "true"},
"class-name", new Class[] {StoreManager.class, String.class}, new Object[] {this, elem.getName()});
uniqueGeneratorsByName.put(elem.getName(), generator);
}
}
}
catch (Exception e)
{
}


Re: Custom Value Generator is not working in 5.2

Andy
 

Sure some classes have been refactored over the years, but then since people can't be bothered to "get involved" with open source then docs don't get updated sometimes.

As can be seen here, any plugin registered generators are loaded when "unique" is true. All built-in generators use the exact same API, so suggest that you use those for reference.


Custom Value Generator is not working in 5.2

ponssaran@...
 

The Datanucleus Guide for Value Generator is old and does not correspond to 5.2 API
https://www.datanucleus.org/products/accessplatform_5_2/extensions/extensions.html#store_valuegenerator

There is no such Class org.datanucleus.store.valuegenerator.AbstractValueGenerator
The class that is available now is
org.datanucleus.store.valuegenerator.AbstractGenerator
The constructor of the class is also changed to
public AbstractGenerator(StoreManager storeMgr, String name)

After changing according to the current API when the application is started.
The Map 
ValueGenerationManager.uniqueGeneratorsByName of RDBMSStoreManager is not having the custom value generator.

In Datanucleus 5.0 this is working.

Is it a bug or the way of providing Custom Value Generator is changed?

Can you please help?


Re: javax.jdo (JDO API) 3.2.0-release

Andy
 
Edited

That is Apache JDO, not the DN version of the API jar (what this is talking about). They will only release their version of the API jar at some point in the future when they have their spec releasable.
Report their problems to their mailing list

61 - 80 of 471