Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 24 20:09
    anidotnet commented #216
  • Jun 24 20:03
    frett27 added as member
  • Jun 24 14:35
    anidotnet commented #228
  • Jun 24 09:09
    sheinbergon commented #228
  • Jun 23 18:04
    aleksandar-stefanovic commented #218
  • Jun 23 17:45
    aleksandar-stefanovic commented #218
  • Jun 23 09:56
    anidotnet commented #228
  • Jun 23 09:55
    anidotnet commented #228
  • Jun 23 09:21
    sheinbergon commented #228
  • Jun 23 09:19
    sheinbergon opened #228
  • Jun 22 15:44
    anidotnet commented #216
  • Jun 22 11:12
    frett27 commented #216
  • Jun 21 19:03
    anidotnet commented #216
  • Jun 21 18:31
    frett27 commented #216
  • Jun 19 10:22
    anidotnet commented #216
  • Jun 19 08:56
    frett27 commented #216
  • Jun 16 12:14
    anidotnet closed #227
  • Jun 16 12:14
    anidotnet commented #227
  • Jun 16 12:06
    aukhatov opened #227
  • Jun 10 12:07
    aukhatov commented #226
newk5
@newk5
I wouldn't mind this limitation after the webapp is in production, but during the development stages I really need to be able to apply changes to my webapp without having to restart the whole server
Anindya Chatterjee
@anidotnet
As nitrite is an embedded database, so placing a lock is logical to keep the database consistent and prevent corruption. In your use case one thing you can do is to create a lite db server around nitrite. Expose your basic functionalities as a rest web service from a separated app and embed nitrite to that application. Now all your glashfish containers need to talk to the rest api application to accomplish your task. In that way you can maintain only one instance of nitrite for a cluster of your glashfish servers.
newk5
@newk5
yea I understand the need for a lock but there's some embedded databases (like SQLite for example) that allow multiple processes to acess the DB and I was hoping nitrite could work similarly
newk5
@newk5
I thought about creating a webservice layer but then I'd have to work on exposing all the needed functionalities, it would be twice the work and I would be solving a "temporary" issue which only happens during the development stages and will never happen when the app is in production
I'm going to re-evaluate my app and see if I can find an alternative solution to this issue
thank you for your help regardless
Georg Leber
@GeorgHenkel
Hi, I have some problems with finding my Objects in the Nitrite DB. I have a created a minimal test case showing my problem: https://github.com/GeorgHenkel/nitrite-repository-test What am I doing wrong?
Georg Leber
@GeorgHenkel
I've found out that, when the field "normDesignation" is used in the FullText-Index, the find call does not return any result. Another problem I've figured out with another usecase is, that the id field cannot be of type UUID. The find call does not find any entry, if searched by id.
Anindya Chatterjee
@anidotnet
Try using ObjectFilters.text("normDesignation", "M1") instead of ObjectFilters.eq("normDesignation", "M1"). When a field is full-text indexed, text filter need to be used.
@GeorgHenkel ^^
Angelos Veglektsis
@angelix
Is it possible to use a cursor directly with a RecyclerView rather than converting it to a .toList() ? Cursor doesn't have a method to get a record by position.
Anindya Chatterjee
@anidotnet
Cursor is an Iterable which cannot be used on a RecyclerView.
Nalaxon
@Nalaxon

Hi, I am new to nosql DBs and Nitrite DB.
I would like to add a new Field "newField" for all Adress - Objects, which is nested in other objects.
Adress has no ID, so I can't do an update as far as I understood.
How could that be done?
My first thought was to do a projection and make updates for each entry I get:

org.dizitart.no2.objects.Cursor<Adress> projection = repo.find();
projection.forEach( adress -> updateWithDefault(repo, adress);

Where updateWithDefault just fill in a default vaule for the new field and call update.
Dokumentation on projections

Any hint is welcome.
Thanks a lot in advance

Anindya Chatterjee
@anidotnet
@Nalaxon you can use filter during update if you don't have id. You can use this method WriteResult update(ObjectFilter filter, T update, boolean upsert) to do what you want.
Angelos Veglektsis
@angelix
@anidotnet latest release 3.3.0 broke the doc.remove(KEY) functionality, now i use doc.put(KEY, null) to clear a field from a fetched document.
Is this expected behaviour?
Anindya Chatterjee
@anidotnet
@angelix a Document is just a LinkedHashMap. No new method has been added or modified in the Document class in this release. What error are you getting now?
For removing, you can also get the iterator from the document and call iterator.remove().
Nalaxon
@Nalaxon

@anidotnet Thanks for your respons.
It seems that I missing something in the concept...

I fail to find Elements within a list.
This is what I tried, but only the first one is matching the entry as expected, the others doesn't macht anything

            Cursor<Company> elemMatch = repository.find(ObjectFilters.elemMatch("randomNumbers",
                ObjectFilters.eq( "$", 2 )
            ));

            Cursor<Company> elemMatchEmployee = repository.find(ObjectFilters.elemMatch("firstName",
                ObjectFilters.eq( "$", "Chief" )
            ));

            Cursor<Company> subElemMatch = repository.find(ObjectFilters.elemMatch("employees",
                ObjectFilters.eq( "$.firstName", "Chief" )));
            Cursor<Company> equal = repository.find(ObjectFilters.eq("firstName", "Chief"));

This is the export of my playground database.

Any hints, what I am missing here?
I also tried the parent.child notation, but it doesn't help in a way

What I really want to do here, is to add an element like "referenceActive" : true for all employees.
The above code was an attempt to understand how the db is working

{
  "collections" : [ ],
  "repositories" : [ {
    "type" : "Company",
    "indices" : [ ],
    "data" : [ {
      "key" : 26471372778100,
      "value" : {
        "name" : "theNewOne",
        "number" : "4864648",
        "randomNumbers" : [ 1, 2, 3, 4, 5, 6, 7 ],
        "employees" : [ {
          "firstName" : "Mr",
          "lastName" : "One",
          "employeeNumber" : [ 1, 2, 3, 4, 5, 6, 7 ]
        }, {
          "firstName" : "Mrs.",
          "lastName" : "Two",
          "employeeNumber" : [ 1, 2, 3, 4, 5, 6, 7 ]
        }, {
          "firstName" : "Chief",
          "lastName" : "One",
          "employeeNumber" : [ 1, 2, 3, 4, 5, 6, 7 ]
        }, {
          "firstName" : "Chief",
          "lastName" : "Two",
          "employeeNumber" : [ 1, 2, 3, 4, 5, 6, 7 ]
        }, {
          "firstName" : "Chief",
          "lastName" : "Three",
          "employeeNumber" : [ 1, 2, 3, 4, 5, 6, 7 ]
        } ],
        "_id" : 26471372778100,
        "_revision" : 1,
        "_modified" : 1571838767470
      }
    } ]
  } ]
}
Anindya Chatterjee
@anidotnet

@Nalaxon you can't update all embedded objects in a single update call. Having said that, you can do these thing. You add a new field referenceActive in Employee object. Now execute these statements

Cursor<Company> companies = repository.find(eq("name", "theNewOne"));
for (Company company : companies) {
       for (Employee employee : company.getEmployees()) {
                employee.setReferenceActive(true);
       }
       repository.update(eq("name", "theNewOne"), company);
}

this will update all Employee objects inside the filtered Company data.

You can see the data before and after update in nitrite explorer
Nalaxon
@Nalaxon

@anidotnet Ah! I see. Thank you so much!

Best Wishes Nox

Nalaxon
@Nalaxon

Hi Again :)
I have a problem to understand the export routine.
I get and ClassNotFoundException (org.example.migration.model.Company+id), if I put Company in a lib and add this again to my migration project as dependency.
The migration project then exports the ObjectStore.
I add the jar file as dependency.

I was able to export an existing ObjectStore, by drop the dependencies.
With dpendencies I am able to manipulate the ObjectStore.
But I am not able to do both, manipulate the ObjectStore and export it as json.

This is possible more of an java issue, but I hoped you can give me an direction where to look.

Thanks a lot in advance!

Anindya Chatterjee
@anidotnet
@Nalaxon I did not fully understand what you are trying to achieve. If I understood you correctly, you want to export and then import an object repository. If that is the case then you need to have the class (the type of the object repository) in the classpath of the program where you do the export routine, as well as import routine.
Nalaxon
@Nalaxon

@anidotnet Sry, for my late answer.
I would like to do the following:
1.) export ObjectStore into json file
2.) update some Objects
I can do both, but not in the same program, because as soon as I import Objects I need for the second step, I get an ClassNotFoundExceptionin the first step.

Why do we want to do the first step:

  • We simply want to be able to export the DB
  • We would like to use the zipped json files to do backups, because it seems that they are smaller in size than zippped db files

I hope this clarified a bit what I try to achieve.

Anindya Chatterjee
@anidotnet
Create a common library where you would put your entity files (e.g. Company class). Use the common library in program 1 where you will export the object and in the program 2 also where you wan to update the object. In this way Company class will always be there in your programs(both 1 and 2) as a library. I hope I have answered your question. If not, please create a small demo project explaining what you want to do and which also reproduce the error you are facing. That will really help to debug your issue.
Angelos Veglektsis
@angelix
FYI We have some exception reports when creating an index.
org.dizitart.no2.exceptions.IndexingException: 
  at org.dizitart.no2.internals.IndexingService.createIndex (IndexingService.java:74)
  at org.dizitart.no2.internals.NitriteService.createIndex (NitriteService.java:225)
  at org.dizitart.no2.internals.DefaultNitriteCollection.createIndex (DefaultNitriteCollection.java:74)

if (!mNitriteProperties.hasIndex(KEY_DB_KEY) && !mNitriteProperties.isIndexing(KEY_DB_KEY)) {
      mNitriteProperties.createIndex(KEY_DB_KEY, IndexOptions.indexOptions(IndexType.Unique, true));
}
Anindya Chatterjee
@anidotnet
@angelix which version of nitrite are you using and what error code it is throwing?
Angelos Veglektsis
@angelix

@anidotnet Nitrite v3.3.0

Caused by org.dizitart.no2.exceptions.IndexingException
NO2.5005: index already exists on key

Anindya Chatterjee
@anidotnet
@angelix it might be a synchronization issue. Try to move createIndex call out of your app's multithreading logic. Meantime, please share me some reproducible code.
Anindya Chatterjee
@anidotnet
@angelix is it possible for you to test your code against 3.4.0-SNAPSHOT?
Melvin Snijders
@TheMelvinNL
Is it possible to do a case insensitive search?
Anindya Chatterjee
@anidotnet
@TheMelvinNL you can use regex filter and use case-insensitive pattern. This SO question might help you - https://stackoverflow.com/questions/3436118/is-java-regex-case-insensitive
Dinesh
@dinbtechit
Hi @anidotnet , do you have any examples for exposing nitrite collections as a reactive streams Restful API?
Anindya Chatterjee
@anidotnet
@dinbtechit nope I don't have any ready made example.
Dinesh
@dinbtechit

@anidotnet - ok no worries Anindya I'll try to create something. But have a rookie question. The in-memory instance doesn't seem to store anything in the heap. I'm always getting null or actually nothing is returned. what am I doing wrong here?

// In Memory instance
Nitrite db = Nitrite.builder()
        .openOrCreate();

// Creating repository
 ObjectRepository<Employee> repository = db.getRepository(Employee.class);

// Inserting Employee
Employee emp = new Employee();
emp.setEmpId(12564);
emp.setAddress("12 Some Street");
repository.insert(employees);

// Listing all the employees
List<Employee> employees =  repository.find().toList();
for (Employee employee: employees) {
   System.out.println(employee);
}

Output - No records are being returned.

Any clue what am I doing wrong here?

Anindya Chatterjee
@anidotnet
@dinbtechit if you change repository.insert(employees); to repository.insert(emp); it works.
Dinesh
@dinbtechit
@anidotnet - Oops there was a typo in my question. I meant to type repository.insert(emp); 😀. It doesn't seem to store anything in the memory.
Anindya Chatterjee
@anidotnet
That is very strange. It seems to be working fine for me. Are you getting any error message?
Dinesh
@dinbtechit
There is no errors at all. I'm really baffled too.
It works fine if I store them in a file. Its just the in-memory. Doesn't want to store anything.
I'm running it on Jetty as a web application. Not sure if that makes any difference though.
Anindya Chatterjee
@anidotnet
OK just do one thing. Create a maven project, reproduce your issue and send me the project. I'll see what's going on
send me at anindya @ dizitart.com
Dinesh
@dinbtechit
sure.. on it.
Anindya Chatterjee
@anidotnet
I saw your code. There are 2 things.
a. If you want to maintain 2 types of db, you must create 2 separate Nitrite variables.
b. In your closeConnection method, you are closing the db. In-memory db is not persistent. As soon as you close the db, it looses data unlike file store db.
Dinesh
@dinbtechit
Thanks Anindya. Appreciate your response. Actually I just want to maintain the in-memory version of the db. The github code that I provided was more of an example to demonstrate 2 different behaviors. Unfortunately, I see the same behavior even if I don't close the connection and/or use a different variables.
Anindya Chatterjee
@anidotnet
@dinbtechit here is the final version of DatabaseConnection file which works