This repository has been archived by the owner on Jun 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
marcust/TroyORM
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
TroyORM - An OR Mapper for MongoDB from hell. It is work in progress :). Annotation based immutable bean mapping (that explains the "from hell" part): // Optional name for collection to be used, otherwise the class name will be used @TroyCollectionName("book") public class Book { @TroyId private final String _isbn; // optional mapping of field to different key in mongo @TroyKey("titleOfBook") private final String _title; // will be stored as author private final String _author; @TroyTransient private final String _dontWantToStoreThis = "foo"; private Book(String isbn, String title, String author) { super(); _isbn = isbn; _title = title; _author = author; } public static Book create( final String isbn, final String title, final String author ) { return new Book( isbn, title, author ); } } Object Based Read and Write: final TroyORMDAOFactory factory = TroyORMDAOFactory.create("troy-test"); final TroyDAO<Book> bookDao = factory.makeDaoForClass( Book.class ); final String key = "1234" + System.currentTimeMillis(); final Book book = Book.create( key, "MongoDB & Troy", "Marcus Thiesen et al."); bookDao.insert(book); System.out.println("Created book with key " + key ); final Book loadedBook = bookDao.query().byId( key ); System.out.println( "Loaded " + loadedBook.toString() ); final BookTitleRefresh refresh = BookTitleRefresh.create( key, "MongoDB & TroyORM" ); bookDao.updaterFor( BookTitleRefresh.class ).update( refresh ); System.out.println("Updated Book"); final Book loadedModifiedBook = bookDao.query().byId( key ); System.out.println( "Loaded Modified " + loadedModifiedBook.toString() ); See org.thiesen.troy.example.Main for more and up to date examples.
About
An OR-Mapper for MongoDB from hell
Resources
Stars
Watchers
Forks
Packages 0
No packages published