SlideShare une entreprise Scribd logo
1  sur  22
Télécharger pour lire hors ligne
Boost your
Java Enterprise Stack
with MongoDB
!
!

bernd@mongosoup.de / twitter: @Bernd_Z
christian@mongosoup.de
!
26. Nov. 2013 @ Leightweight Java User Group Munich
Continuous Delivery
Standard JEE Stack
Frontend Layer
Service Layer
Repository Layer
MongoDB
{

}

"_id" : ObjectId("51f2ce49c2e6dce83534b73f"),
"orderId" : NumberLong(666),
"orderItems" : [
{
"product" : {
"_id" : ObjectId("51f2ce48c2e6dce83534b6ba"),
"articleId" : "100",
"name" : "Margherita",
"urlname" : "margherita",
"description" : "our famous tomato sauce and genuine mozzarella",
"type" : "PIZZA",
"category" : "vegetarian",
"price" : 3.8
},
"uuid" : "839f8305-a5e7-408a-96d5-e3d2819d6ad3"
}
],
"orderDate" : ISODate("2011-09-13T07:24:00Z"),
"deliveryAddress" : {
"firstname" : "Christan",
"lastname" : "Kroemer",
"street" : „Lindwurm Straße",
"zip" : "80337",
"city" : "Munich",
"houseNumber" : "97"
},
"userId" : "51f2ce48c2e6dce83534b70b"
Hibernate ORM
@Entity
@Table(name = „ORDER")
public class Order implements Serializable {

!

!

@Id
@GeneratedValue
@Column(name="ID")
private Long id;

mapping of POJOs to relational database tables

!

@OneToOne(cascade = CascadeType.ALL, optional = false, orphanRemoval = false)
@JoinColumn(name = "USER_ID", nullable = false)
@ForeignKey(name = "ORDER_USER_FK")
private User user;
@OneToMany(mappedBy = "order")
@Fetch(FetchMode.JOIN)
private List<OrderItem> orderItems;
Spring Data
@Document(collection = Order.COLLECTION_NAME)
public class Order implements Serializable {
public static final String COLLECTION_NAME = "order";

!
@Id
private ObjectId id;

!
@Indexed(unique = true)
annotated sample class here
private long orderId;

!
@DBRef
private User user;
private List<OrderItem> orderItems;

!
@Indexed
private Date orderDate = new Date();
Unit Tests
- Fast
- Isolated
- Repeatable

relational in memory DB for testing

- Self-verifying
- Timely
DBUnit
<?xml version="1.0" encoding="UTF-8"?>
<dataset>
<User id="0" title="Mr" firstName="Bernd" lastName="Zuther"/>
<User id="1" title="Mr" firstName="Christian" lastName="Kroemer"/>
</dataset>

@Test
@DatabaseSetup("sampleData.xml")
public void testFind() throws Exception {
List<User> userList = userService.findByName("Christian");
assertEquals(1, userList.size());
assertEquals("Christian", userList.get(0).getFirstName());
}
Fongo
<dependency>
<groupId>com.github.fakemongo</groupId>
<artifactId>fongo</artifactId>
<version>1.3.2</version>
</dependency>

!
!
!
alternative for the Mongo world
!
TODO: does mongo soup fit in there anywhere?
<bean name="fongo" class=“com.github.fakemongo.Fongo">
<constructor-arg value="InMemoryMongo" />
</bean>

!
<bean id="mongo" factory-bean="fongo" factory-method="getMongo" />
NoSQLUnit
@ActiveProfiles("test")
@ContextConfiguration(locations = "classpath:com/comsysto/shop/ui/spring-context.xml")
@UsingDataSet(locations="initialData.json", loadStrategy=LoadStrategyEnum.CLEAN_INSERT)
public class OrderRepositoryImplTest extends AbstractJUnit4SpringContextTests {

!

!

}

@Autowired private OrderRepository orderRepository;
@Autowired private ApplicationContext applicationContext;

Presenter
@Rule public MongoDbRule mongoDbRule = newMongoDbRule().defaultSpringMongoDb("pizza");
@Test
public void testFindAll() {
Sort sortOrder = new Sort(Sort.Direction.ASC, "orderId");
List<Order> retrievedOrders = orderRepository.findAll(10, 0, sortOrder);
assertNotNull(retrievedOrders);
assertEquals(5, retrievedOrders.size());
}
Continuous Delivery
Infrastructure
Danger Area
Downtime
Flyway

relational in memory DB for testing
Flyway

relational in memory DB for testing
MongoDB - Schemaless

{ name : "Bernd", age : 30, interests : "football" }

!

{ name : "Christian", age : 25 }
relational in memory DB for testing
MongoDB - Schemaless

relational in memory DB for testing
Build... Test... Live!

https://github.com/comsysto/mongodb-onlineshop/
Questions

Presenter

Contenu connexe

Plus de Bernd Zuther

Building an Online-Recommendation Engine with MongoDB
Building an Online-Recommendation Engine with MongoDBBuilding an Online-Recommendation Engine with MongoDB
Building an Online-Recommendation Engine with MongoDBBernd Zuther
 
Building an-online-recommendation-engine-with-mongodb-cebit-hannover
Building an-online-recommendation-engine-with-mongodb-cebit-hannoverBuilding an-online-recommendation-engine-with-mongodb-cebit-hannover
Building an-online-recommendation-engine-with-mongodb-cebit-hannoverBernd Zuther
 
Building an Online-Recommendation Engine with MongoDB
Building an Online-Recommendation Engine with MongoDBBuilding an Online-Recommendation Engine with MongoDB
Building an Online-Recommendation Engine with MongoDBBernd Zuther
 
Building an Online-Recommendation Engine with MongoDB
Building an Online-Recommendation Engine with MongoDBBuilding an Online-Recommendation Engine with MongoDB
Building an Online-Recommendation Engine with MongoDBBernd Zuther
 
Mongodb + Hadoop Big Data Solyanka
Mongodb + Hadoop Big Data SolyankaMongodb + Hadoop Big Data Solyanka
Mongodb + Hadoop Big Data SolyankaBernd Zuther
 
Real time Analytics with MongoDB
Real time Analytics with MongoDBReal time Analytics with MongoDB
Real time Analytics with MongoDBBernd Zuther
 

Plus de Bernd Zuther (6)

Building an Online-Recommendation Engine with MongoDB
Building an Online-Recommendation Engine with MongoDBBuilding an Online-Recommendation Engine with MongoDB
Building an Online-Recommendation Engine with MongoDB
 
Building an-online-recommendation-engine-with-mongodb-cebit-hannover
Building an-online-recommendation-engine-with-mongodb-cebit-hannoverBuilding an-online-recommendation-engine-with-mongodb-cebit-hannover
Building an-online-recommendation-engine-with-mongodb-cebit-hannover
 
Building an Online-Recommendation Engine with MongoDB
Building an Online-Recommendation Engine with MongoDBBuilding an Online-Recommendation Engine with MongoDB
Building an Online-Recommendation Engine with MongoDB
 
Building an Online-Recommendation Engine with MongoDB
Building an Online-Recommendation Engine with MongoDBBuilding an Online-Recommendation Engine with MongoDB
Building an Online-Recommendation Engine with MongoDB
 
Mongodb + Hadoop Big Data Solyanka
Mongodb + Hadoop Big Data SolyankaMongodb + Hadoop Big Data Solyanka
Mongodb + Hadoop Big Data Solyanka
 
Real time Analytics with MongoDB
Real time Analytics with MongoDBReal time Analytics with MongoDB
Real time Analytics with MongoDB
 

Dernier

ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 

Dernier (20)

ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 

LJUGM - Boost your Java Enterprise Stack with MongoDB