Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified json file make collectionExist return false #41

Closed
DataMirko opened this issue Aug 12, 2020 · 2 comments
Closed

Modified json file make collectionExist return false #41

DataMirko opened this issue Aug 12, 2020 · 2 comments

Comments

@DataMirko
Copy link

Hi!
I have 2 json db file. One for user (users.json) and one for transactions (transactions.json)
Everytime i run the java application. The transactions.json file is rewritten and i loose every data in it.
When i add some data in the file, the jsonDBTemplate.collectionExists(Transaction.class) return false so a new transactions.json is written.

ph

@DataMirko
Copy link
Author

There was a mistake in the json file. Data could not loaded correctly in the java Class field

@byronv5
Copy link

byronv5 commented Feb 22, 2024

Each JsonDBTemplate corresponding to dbFilesLocationString must be a singleton. Otherwise, when a second thread creates a new JsonDBTemplate(...), calling the lock method will throw an OverlappingFileLockException exception. After the exception occurs, the corresponding data item in collectionsRef will be deleted. Subsequently, when calling collectionExists, it will return false. Ultimately, if we invoke createCollection, it will overwrite the original file, resulting in data deletion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants