ObjectDB ObjectDB

Issue #2722: ObjectDB needs "insert ignore"

Type: Feature RequestVersion: 2.8.6Priority: NormalStatus: ActiveReplies: 7
#1

Hi,

The command "insert ignore into" in mysql can avoid interruptions caused by program errors when the id is repeated. In a certain situation, we need to remove duplicates from a lot of duplicated data through some rule, and hashmap can do the job. But it would be nice if the database could do it with a few memory.

I agree the point in the following post, but I cannot reply it. So I have to create a repeated topic.

how to implement insert ignore in objectdb?

edit
delete
#2

The post was added as a new feature request.

ObjectDB Support
edit
delete
#3

Without the function "IGNORE", I have to do this for inserting:


@NamedQuery(
        name="isExistName",
        query="SELECT count(c) FROM Student c WHERE c.name = :stuName and c.sid=:stuID"
)
then run createNamedQuery("isExistName"), judge whether the student exist.

Is there an elegant method for repeated inserting?

edit
delete
#4

It is fine. However, to check if a specific primary key is in use, you may also use find or getReferemce (see this page). Use an ID class or an embedded ID as the second parameter if  you have  a composite primary key (see this page).

ObjectDB Support
edit
delete
#5

I've discussed "find() cost unreasonable time!".

You'd pointed this "Find is very efficient in retrieving a single entity object but less efficient when many entity objects" and "In that case - you should use a query."

in the post : https://www.objectdb.com/forum/359

edit
delete
#6

> You'd pointed this "Find is very efficient in retrieving a single entity object but less efficient when many entity objects" and "In that case - you should use a query."

That is correct, but apparently in #3 above you are checking a single object in that operation, so find is expected to be a bit faster in that case (and check also getReference, which could be faster).

ObjectDB Support
edit
delete
#7

Hi, what about the new feature request?

edit
delete
#8

How do you get the duplicate primary key error? Are you using persist?

You may try merge instead, which should work with existing primary keys as well.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.