Does toplink reflect changes in the order - java

Does top link reflect the changes if the ordering of the elements have changed? I have the below mapping :
ManyToManyMapping dummyMapping = new ManyToManyMapping();
dummyMapping.setAttributeName("dummy");
dummyMapping.setReferenceClass(Dummy.class);
dummyMapping.useBasicIndirection();
//aggregationProvidersMapping.useCollectionClass(java.util.ArrayList.class);
dummyMapping.setRelationTableName("DUMMY");
dummyMapping.addSourceRelationKeyFieldName("dummy1.ID", "dummy2.ID");
dummyMapping.addTargetRelationKeyFieldName("dummy1.ORGID", "dummy2.id");
descriptor.addMapping(dummyMapping);
What is the default collection class used if I don't specify any class via the "useCollectionClass"?
"dummy" is using a ArrayList and hence the ordering of the elements is maintained. If the ordering of the elements within the "dummy" attribute has changed, [no additions or deletions], does toplink reflect these changes to the DB ?

For a ManyToManyMapping ,there is no way in which the order can be stored. I resolved this solution by changing to OneToManyMapping.

Related

Migration from JDK8 to JDK11 causing java.lang.UnsupportedOperationException

You you can see from the class name properties.stringPropertyNames() returns an Collections$UnmodifiableCollection. Unmodifiable means you can't add, insert, remove or change something on this collection
Now that you have explained what the type of properties is java.util.Properties the answer is clear. In Java 8, Properties.stringPropertyNames() returned a set whose modifiability was unspecified:
"Returns a set of keys in this property list where the key and its corresponding value are strings, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list. Properties whose key or value is not of type String are omitted."
"The returned set is not backed by the Properties object. Changes to this Properties are not reflected in the set, or vice versa.".
In Java 11, it is specified to be unmodifiable.
"Returns an unmodifiable set of keys from this property list where the key and its corresponding value are strings, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list. Properties whose key or value is not of type String are omitted."
"The returned set is not backed by this Properties object. Changes to this Properties object are not reflected in the returned set."
The change happened in Java 9. This is related to bug 8059361.
(This is was an incompatible change in the sense that it could break customers' code if they relied on being able to modify the returned set. However, that code was relying on unspecified behavior, so you could argue that it was broken already.)
As i understand correctly, you have unmodifiable set and you are tying to change it here
parameterNames.removeIf(s -> !s.startsWith(seq));
that's why you getting this error/exception.
Set<String> parameterNames = new HashSet<>(properties.stringPropertyNames());
This will create a new Set with same content which can be altered.

Efficient way redis set member update

I have a redis set. This set can store 20 members maximum(added withSADD command).
My problem is ; I need to update that members when needed. Members need that modification maximum 10 times for every member. Set members are json as a string. There is only solutoin on my mind nor, get all members update and recreate that set again. But it seems iditoic.
I know there is ZADD sorted set with its score support it seems suitable also I need to update score like data in json , but i just wonder Is there any method updating members in efficient way, or is updating member not acceptable on redis way ?
Note: Redis datastore is using by both node.js and java clients.
Set members themselves are immutable - you can add new members or remove existing ones. That's it.
Given that a set is an unordered collection of unique members, consider the possible outcomes were set members theoretically modifiable when the new value for a member:
is identical to the old value - no change to the set
already exists in the set - equivalent to deleting that member
isn't 1 or 2 - equivalent to deleting the member and adding a new one

How to use OptaPlanner ValueRange from planning entity?

I'm attempting to limit the planning variables that can be associated with a particular entity. In the OptaPlanner manual in section 4.3.4.2.2, an example is shown, but it isn't clear how the list of variables should be generated. What should the list contain? Are these planning variables themselves? Can they be copies? If copies are allowed, then how are they compared? If not, the planning variable is not in scope when defining the planning entity - I realize that this is a Java question, but it isn't apparent how to access the list of planning variables from the planning entity definition.
Is this is a 6.1 feature that was not supported in earlier versions?
Will the Working Memory size be constrained by using this feature? That is my goal.
Your assistance is greatly appreciated!
Here's the example from the manual:
#PlanningVariable
#ValueRange(type = ValueRangeType.FROM_PLANNING_ENTITY_PROPERTY, planningEntityProperty = "possibleRoomList")
public Room getRoom() {
return room;
}
public List<Room> getPossibleRoomList() {
return getCourse().getTeacher().getPossibleRoomList();
}
Let's set the terminology straight first: The planning variable (for example getRoom() in the example) has a value range (which is a list of planning values) which different from entity instance to entity instance.
About such a List of planning values:
Each entity has it's own List instance, although multiple entities can share the same List instance if they have the exact same value range.
No copies: A planning value instance should only exists once in a Solution. So 2 entities with different value ranges, but with the same planning value in their value ranges, should be using the same planning value instance.

Updating values of functional data properties doesn't remove old values, only adds new triples

I have an RDF Ontology with a functional property hasTrendValue which relates instances of a class with integer values. I want to change these values programmatically using Jena. I tried the following code:
Property hasTrend = ontModel.getDatatypeProperty(preFix+"hasTrendValue");
Individual regionQualifier = ontModel.getIndividual(activityName);
ontModel.addLiteral(regionQualifier,hasTrend,34);
PrintStream p = new PrintStream(ontoPath);
ontModel.write(p,null);
p.close();
This code executes correctly but, it does not update the already hasTrendValue value in the RDF; instead it adds a new hasTrendValue to the RDF ontology even though it declared as a functional property. What is the better way of doing this?
RDF does not have the concept of "change", only "add" and "remove". To change a value, you need to remove the old one and add the new one.
Declaring it as a functional property does not change this. Jena does not check the ontology on every operation. In fact, a functional property says that the object identifies one thing - it may be written in many ways. 001 and 1 are the same value. There may be multiple triples, it's not automatically wrong.

Objectify: Get list of Strings NOT EQUAL to provided value

I need to get the list of items whose datePublished IS NOT "". However, the code below doesn't work. Any ideas? Thanks
Query<Diagram> q=ofy.query(Diagram.class).filter("datePublished !=", "").order("-likes").limit(18);
When applying an inequality filter in the GAE datastore there are some restrictions.
You can read more here: https://developers.google.com/appengine/docs/java/datastore/queries
In this case, to have an inequality on datePublished you must order on that same field primarily before you can order on another.
So assuming the datePublished field is indexed:
Query<Diagram> q=ofy.query(Diagram.class).filter("datePublished !=", "").order("datePublished").order("-likes").limit(18);
Assuming this isn't a migration concern, you may want to consider denormalising this data when you store it, for example setting a 'noDatePublished' boolean.

Categories

Resources