SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 

Kürzlich hochgeladen (20)

Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 

LJUGM - Boost your Java Enterprise Stack with MongoDB