0 votes
asked in MicroStream for Java by (590 points)
edited by

I play around with microstream DB and got a situation which I can not explain.
I created two functions, to delete a specific datarow in a microstream table-object.
My first function did not work. The code runs through, but the row was not deleted

	public static void deleteById(final Long in)
		final Logger logger = LoggerFactory.getLogger(MsTIdeaDAO.class);
		logger.info("The datarow with Id should be deleted, Id: " + in.toString());

		final Optional<MsTidea> matchedIdea =
				.filter(f -> f.getId().equals(in))

			logger.info("There is a datarow available, with the ObjectId: " + matchedIdea.toString());

Then I modified it as the second:

	public static void deleteById2(final Long in)
		final Logger logger = LoggerFactory.getLogger(MsTIdeaDAO.class);
		logger.info("The datarow with Id should be deleted, Id: " + in.toString());
		MsTidea myDelIdea = null;
		for(final MsTidea MsTidea : DbHandler.getRoot().getAllMsTidea())
			if(MsTidea.getId() == in)
				myDelIdea = MsTidea;
				logger.info("There is a datarow available, with the ObjectId: " + myDelIdea.toString());
		if(myDelIdea != null)

The second one worked perfect.
For both I gave as input an integer value, perhaps 3.
The 3 is available in my datarow object, in a field called "id"
Both got a hit, the id and the ObjectID are in both identical

Another mystic is following:

The above described id-field is defined as Long.
When I use Integer values 1,2,3,.. inside this field the second function, if I try to delete a row it works fine.
The selected row gets deleted.
But when I try to use longer Ids like: 759437634441375744
Then the datarow gets not deleted!

First I thought that something with the compare went wrong..., but if I debug it, there is no difference.
The code walked through each step, in each case the same.

Following shows my class definition (only first lines for the id:

package com.rieder.powerkiss.dbmodel;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.rapidclipse.framework.server.resources.Caption;

 * MsTidea
public class MsTidea implements java.io.Serializable
	private Long   id;
	private String ideaHeadline;
	private String creator;
	private Date   createdDate;
	private Date   lastChangedDate;
	private String longDescription;
	private int    ideaState;
	private int    tableReference;

	public MsTidea()
	@Column(name = "id", unique = true, nullable = false, columnDefinition = "Long")
	public Long getId()
		return this.id;
	public void setId(final Long id)
		this.id = id;


Where is my error? / why the first one did not work?
Any idea?
If you have further questions, please don't hesitate to ask.

Thank you in advance



2 Answers

+1 vote
answered by (9.7k points)
selected by
Best answer

In the method “deleteById” there may be a missing “.get()“ in the line

Changing it to
may help.


Best regards.
commented by (590 points)
Thank you very much!
Yes this trick did it!
0 votes
answered by (590 points)

Ok, I found the reason for the second part of the question. It was my fault, due usage of wrong comparison.
The compare with ...if(MsTidea.getId() == in)... did not work with the long id.
If I use: ...
if(MsTidea.getId().equals(in)) the compare worked as expected.

But Part 1 of the question is still open smiley

Notes: Every question must be a separate forum post. Headline: Formulate your question shortly and precisely. Thank you!
Powered by Question2Answer