SlideShare uma empresa Scribd logo
1 de 53
Object/Relational Mapping Solving the structural paradigm mismatch
Creating a Domain Model ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Item 0..* User 0..* sells Category
Our example application ,[object Object],[object Object],Item 0..* User 0..* sells Bid 0..* 0..* Address 0..* BillingDetails CreditCard BankAccount home billing 0..* Category
Writing POJOs ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],POJO Best Practices are actually requirements of Hibernate for persistent classes.
A simple POJO public class User implements Serializable { private String username; private Address address; public User() {} public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public Address getAddress() { return address;} public void setAddress(Address address) { this.address = address; } public MonetaryAmount calcShippingCosts(Address from) { ... } }
Adding logic to accessor methods ,[object Object],[object Object],public class User { private String firstname; ... public void setFirstname(String firstname) throws InvalidNameException { if ( !StringUtil.isCapitalizedName(firstname) ) throw new InvalidNameException(firstname); this.firstname = firstname; ) ... }
Class mapping ,[object Object],[object Object],[object Object],[object Object],<hibernate-mapping package=&quot;org.hibernate.auction.model&quot; schema=&quot;AUCTION&quot;> <class name=&quot;User&quot; table=&quot;USER&quot; dynamic-insert=&quot;true&quot; dynamic-update=&quot;true&quot;> </class> ... </hibernate-mapping>
Property mapping ,[object Object],[object Object],<!- An immutable property --> <property name=&quot;orderNumber&quot; column=&quot;ORDER_NR&quot; type=&quot;string&quot; not-null=&quot;true&quot; access=&quot;field&quot; update=&quot;false&quot;/> <!-- A derived property (read only) --> <property name=&quot;totalIncludingTax&quot; formula=”PRICE + PRICE * TAX_RATE&quot; type=&quot;big_decimal&quot;/>
Writing persistent classes ,[object Object],0..* public class Category { private String name; private Category  parentCategory ; private Set  childCategories  = new HashSet(); Set getChildCategories() { return childCategories; } void setChildCategories(Set categories) { childCategories = categories; } public Category getParentCategory() {  return parentCategory(); } void setParentCategory(Category category) { parentCategory = category; } } Category
Optimizing association handling ,[object Object],[object Object],[object Object],[object Object],[object Object],public void addChildCategory(Category child) { // Be defensive! if (child == null) throw new IllegalArgumentException(&quot;null Child&quot;); // Ensure multiplicity if ( child.getParent() != null ) child.getParent().getChildCategories().remove(child); child.setParent(this); getChildCategories().add(child); }
Primary keys ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Database identity in Hibernate ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],public class Category { private Long id = null; public Long getId() { return this.id; } private void setId(Long id) { this.id = id; } }
Identity mapping ,[object Object],[object Object],[object Object],[object Object],<class name=&quot;Category&quot; table=&quot;CATEGORY&quot;> <id name=&quot;id&quot; column=&quot;CATEGORY_ID&quot; type=&quot; long &quot;> <generator class=&quot; native &quot;/> </id> ... </class>
Identifier generation strategies ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Hibernate type system ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Built-in value types ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Composition in our object model ,[object Object],User Address home billing class User { private Long id; private Address homeAddress; private Address billingAddress; } class Address { private String street; private String zipcode; private String city; }
Mapping components ,[object Object],[object Object],<class name=&quot;User&quot; table=&quot; USER &quot;> <id name=&quot;id&quot; column=&quot;USER_ID&quot;> <generator class=&quot;native&quot;/> </id> <component name=&quot;homeAddress&quot; class=&quot;Address&quot;> <property name=&quot;street&quot; column=&quot; HOME_STREET &quot; not-null=&quot;true&quot;/> <property name=&quot;city&quot; column=&quot; HOME_CITY &quot;  not-null=&quot;true&quot;/> <property name=&quot;zipcode&quot; column=&quot; HOME_ZIPCODE &quot; not-null=&quot;true&quot;/> </component> ... </class>
Bidirectional component mapping ,[object Object],[object Object],[object Object],<component name=&quot;homeAddress&quot; class=&quot;Address&quot;> <parent name=&quot;user&quot;/> <property name=&quot;street&quot; column=&quot; HOME_STREET &quot; not-null=&quot;true&quot;/> <property name=&quot;city&quot; column=&quot; HOME_CITY &quot;  not-null=&quot;true&quot;/> <property name=&quot;zipcode&quot; column=&quot; HOME_ZIPCODE &quot; not-null=&quot;true&quot;/> </component>
Class inheritance hierarchies ,[object Object],[object Object],[object Object],[object Object],BillingDetails CreditCard BankAccount
Table per concrete class mapping ,[object Object],[object Object],[object Object],[object Object],<< table >> CREDIT_CARD CREDIT_CARD_ID << PK >> OWNER NUMBER TYPE EXP_DATE << table >> BANK_ACCOUNT BANK_ACCOUNT_ID << PK >> OWNER NUMBER BANK_NAME BANK_SWIFT
Table per class hierarchy ,[object Object],[object Object],[object Object],[object Object],<< table >> BILLING_DETAILS BILLING_DETAILS_ID << PK >> BILLING_TYPE << discriminator >> OWNER NUMBER CREDIT_CARD_TYPE CREDIT_CARD_EXP_DATE BANK_ACCOUNT_NAME BANK_ACCOUNT_SWIFT
Mapping a class hierarchy to a single table ,[object Object],[object Object],<class name=&quot;BillingDetails&quot; table=&quot;BILLING_DETAILS&quot;> <id name=&quot;id&quot; column=&quot;BILLING_DETAILS_ID&quot;> <generator class=&quot;native&quot;/> </id> <discriminator column=&quot;BILLING_TYPE&quot;/> <property name=&quot;name&quot; column=&quot;OWNER&quot;/> ... <subclass name=&quot;CreditCard&quot;  discriminator-value=&quot;CC&quot; > <property name=&quot;type&quot; column=&quot;CREDIT_CARD_TYPE&quot;/> ... </subclass> ... </class>
Table per subclass ,[object Object],[object Object],[object Object],<< table >> CREDIT_CARD CREDIT_CARD_ID <<PK>> <<FK>> TYPE EXP_DATE << table >> BANK_ACCOUNT BANK_ACCOUNT_ID <<PK>> <<FK>> BANK_NAME BANK_SWIFT << table >> BILLING_DETAILS BILLING_DETAILS_ID <<PK>> OWNER NUMBER
Mapping a joined subclass to normalized tables ,[object Object],[object Object],[object Object],<class name=&quot;BillingDetails&quot; table=&quot;BILLING_DETAILS&quot;> <id name=&quot;id&quot; column=&quot;BILLING_DETAILS_ID&quot;> <generator class=&quot;native&quot;/> </id> <property name=&quot;name&quot; column=&quot;OWNER&quot;/> ... <joined-subclass name=&quot;CreditCard&quot; > <key column=&quot;CREDIT_CARD_ID&quot;/> <property name=&quot;type&quot; column=&quot;CREDIT_CARD_TYPE&quot;/> ... </joined-subclass> ... </class>
Class associations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Item Bid 0..*
The tables of this association mapping << table >> ITEM ITEM_ID <<PK>> NAME PRICE ... << table >> BID BID_ID <<PK>> ITEM_ID <<FK>> AMOUNT ... PRICE NAME ITEM_ID 1 2 3 Bar Foo Baz 2.00 50.00 1.00 ITEM AMOUNT ITEM_ID BID_ID 1 2 3 1 1 2 10.00 20.00 55.00 BID
Mapping a unidirectional association ,[object Object],class Bid { private Item item; public void setItem(Item i) { this.item = i; } public Item getItem() { return item; } } <class name=&quot;Bid&quot; table=&quot;BID&quot;> ...  <many-to-one name=&quot;item&quot; class=&quot;Item&quot; column=&quot;ITEM_ID&quot; not-null=&quot;true&quot;/> </class>
Making the association bidirectional ,[object Object],class Item { private Set bids = new HashSet(); public void getBids() { return bids; } public void addBid(Bid b) { this.bids.add(b) b.setItem(this) // Manage association! } } <class name=&quot;Item&quot; table=&quot;ITEM&quot;> ...  <set name=&quot;bids&quot;> <key column=&quot;ITEM_ID&quot;/> <one-to-many class=&quot;Bid&quot;/> </set> </class>
The big problem ,[object Object],[object Object],Hibernate does not transparently detect the fact that the two changes refer to the same database column, since at this point we have done nothing to indicate that this is a bidirectional association. item.getBids().add(newBid); newBid.setItem(item);
Making the association bidirectional ,[object Object],[object Object],[object Object],<class name=&quot;Item&quot; table=&quot;ITEM&quot;> ...  <set name=&quot;bids&quot;  inverse=&quot;true&quot; > <key column=&quot;ITEM_ID&quot;/> <one-to-many class=&quot;Bid&quot;/> </set> </class>
Mapping collections vs Java collections Persists an unordered,non-unique many-to-many collection using a surrogate key. java.util.List idbag Persists an indexed, non-unique collection of primitive values N/A primitive-array Persists an indexed, non-unique collection of values or objects N/A array Persists an unordered, non-unique collection of values or objects java.util.List bag Persists an ordered,non-unique collection of values or objects java.util.List list Persists a collection of key/value pairs java.util.Map map Persists an unordered,unique collection of values or objects java.util.Set set Description Java Collection Type Hibernate Collection Type
One-to-many association <hibernate-mapping package=“demo”> <class name=“Event”  table=“events”> … . <set name=“speakers”> <key column=“event_id”/> <one-to-many  class=“Speaker”/> </set> <set name=“attendees”> <key column=“event_id”/> <one-to-many  class=“Attendee”/> </set> … . </class> </hibernate-mapping> public class Event { private Set speakers; private set attendees; public void setSpeakers(Set speakers) { this.speakers=speakers;} public set getSpeakers() {return this.speakers;} public void setAttendees(Set attendees) { this.attendees=attendees;} public set getAttendees() {return this.attendees;}
One-to-many events events events attendees id bigint(pk) id bigint (pk) event_id bigint (fk) A one-to-many association from events to attendees
Many-to-many ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
many-to-many events events events event_attendees id bigint(pk) event_id bigint (fk) attendee_id bigint (fk) A many-to-many table schema from events to attendees events events attendees id bigint(pk)
Persisting collections of values ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Lists ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Maps ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Bags ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
idbags ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
idbags events events events event_attendees id bigint(pk) event_id bigint  speaker_id bigint  events events speakers id bigint(pk) event_speaker_id bigint (PK)
Lazy collections ,[object Object],[object Object],[object Object],[object Object],[object Object]
Lazy collections – Session closed problem ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Lazy collections – correct method ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Lazy collections – multitier problems ,[object Object],[object Object],[object Object],[object Object],[object Object]
Sorted Collections ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Filters ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Filters - 2 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Filters - 3 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Metadata alternatives ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],/** * @hibernate.class *  table=&quot;CATEGORY&quot; */ public class Category { ... /** * @hibernate.property */ public String getName() { return name; } ... }
Adding a property at runtime // Get the existing mapping for User from Configuration PersistentClass userMapping = cfg .getClassMapping(User.class); // Define a new column for the USER table Column column = new Column(); userMapping.getTable().addColumn(column); // Wrap the column in a Value SimpleValue value = new SimpleValue(); value.setTable( userMapping.getTable() ); value.addColumn(column); // Define a new property of the User class Property prop = new Property(); prop.setValue(value); prop.setName(&quot;motto&quot;); userMapping.addProperty(prop); // Build a new session factory, using the new mapping SessionFactory sf =  cfg.buildSessionFactory();
Reading metadata at runtime ,[object Object],Category category = ...; ClassMetadata meta = sessionFactory.getClassMetadata(Category.class); String[] metaPropertyNames = meta.getPropertyNames(); Object[] propertyValues = meta.getPropertyValues(category);

Mais conteúdo relacionado

Mais procurados

Ap Power Point Chpt7
Ap Power Point Chpt7Ap Power Point Chpt7
Ap Power Point Chpt7dplunkett
 
Object Oriended Programming with Java
Object Oriended Programming with JavaObject Oriended Programming with Java
Object Oriended Programming with JavaJakir Hossain
 
Java Persistence API
Java Persistence APIJava Persistence API
Java Persistence APIIlio Catallo
 
object oriented programming language by c++
object oriented programming language by c++object oriented programming language by c++
object oriented programming language by c++Mohamad Al_hsan
 
Advanced c#
Advanced c#Advanced c#
Advanced c#saranuru
 
Xm Lquickref
Xm LquickrefXm Lquickref
Xm LquickrefLiquidHub
 
Xml Syntax Quick Reference
Xml Syntax Quick ReferenceXml Syntax Quick Reference
Xml Syntax Quick ReferenceLiquidHub
 
Beginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHPBeginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHPRick Ogden
 
How to write you first class in c++ object oriented programming
How to write you first class in c++ object oriented programmingHow to write you first class in c++ object oriented programming
How to write you first class in c++ object oriented programmingSyed Faizan Hassan
 
Object oreinted php | OOPs
Object oreinted php | OOPsObject oreinted php | OOPs
Object oreinted php | OOPsRavi Bhadauria
 
Esoteric LINQ and Structural Madness
Esoteric LINQ and Structural MadnessEsoteric LINQ and Structural Madness
Esoteric LINQ and Structural MadnessChris Eargle
 
Object Oriented Programming Basics with PHP
Object Oriented Programming Basics with PHPObject Oriented Programming Basics with PHP
Object Oriented Programming Basics with PHPDaniel Kline
 
Model Inheritance
Model InheritanceModel Inheritance
Model InheritanceLoren Davie
 
Oop features java presentationshow
Oop features java presentationshowOop features java presentationshow
Oop features java presentationshowilias ahmed
 

Mais procurados (20)

Ap Power Point Chpt7
Ap Power Point Chpt7Ap Power Point Chpt7
Ap Power Point Chpt7
 
Lab 4
Lab 4Lab 4
Lab 4
 
Object Oriended Programming with Java
Object Oriended Programming with JavaObject Oriended Programming with Java
Object Oriended Programming with Java
 
Java Persistence API
Java Persistence APIJava Persistence API
Java Persistence API
 
object oriented programming language by c++
object oriented programming language by c++object oriented programming language by c++
object oriented programming language by c++
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Objects and Types C#
Objects and Types C#Objects and Types C#
Objects and Types C#
 
Advanced c#
Advanced c#Advanced c#
Advanced c#
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
 
Xm Lquickref
Xm LquickrefXm Lquickref
Xm Lquickref
 
Xml Syntax Quick Reference
Xml Syntax Quick ReferenceXml Syntax Quick Reference
Xml Syntax Quick Reference
 
Beginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHPBeginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHP
 
Class and object in C++ By Pawan Thakur
Class and object in C++ By Pawan ThakurClass and object in C++ By Pawan Thakur
Class and object in C++ By Pawan Thakur
 
How to write you first class in c++ object oriented programming
How to write you first class in c++ object oriented programmingHow to write you first class in c++ object oriented programming
How to write you first class in c++ object oriented programming
 
Object oreinted php | OOPs
Object oreinted php | OOPsObject oreinted php | OOPs
Object oreinted php | OOPs
 
Esoteric LINQ and Structural Madness
Esoteric LINQ and Structural MadnessEsoteric LINQ and Structural Madness
Esoteric LINQ and Structural Madness
 
Object Oriented Programming Basics with PHP
Object Oriented Programming Basics with PHPObject Oriented Programming Basics with PHP
Object Oriented Programming Basics with PHP
 
Model Inheritance
Model InheritanceModel Inheritance
Model Inheritance
 
Oop features java presentationshow
Oop features java presentationshowOop features java presentationshow
Oop features java presentationshow
 
PHP Classes and OOPS Concept
PHP Classes and OOPS ConceptPHP Classes and OOPS Concept
PHP Classes and OOPS Concept
 

Destaque

Ling to SQL and Entity Framework performance analysis
Ling to SQL and Entity Framework performance analysisLing to SQL and Entity Framework performance analysis
Ling to SQL and Entity Framework performance analysisAlexander Konduforov
 
ORM을 활용할 경우의 설계, 개발 과정
ORM을 활용할 경우의 설계, 개발 과정ORM을 활용할 경우의 설계, 개발 과정
ORM을 활용할 경우의 설계, 개발 과정Javajigi Jaesung
 
Object Relational Mapping In Real World Applications
Object Relational Mapping In Real World ApplicationsObject Relational Mapping In Real World Applications
Object Relational Mapping In Real World ApplicationsPhilWinstanley
 
What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3Jeremy Coates
 
QnA blog using Django - ORM, 회원가입, 로그인/로그아웃
QnA blog using Django - ORM, 회원가입, 로그인/로그아웃QnA blog using Django - ORM, 회원가입, 로그인/로그아웃
QnA blog using Django - ORM, 회원가입, 로그인/로그아웃Kwangyoun Jung
 
좌충우돌 ORM 개발기 2012 DAUM DEVON
좌충우돌 ORM 개발기 2012 DAUM DEVON좌충우돌 ORM 개발기 2012 DAUM DEVON
좌충우돌 ORM 개발기 2012 DAUM DEVONYounghan Kim
 
Object Relational Mapping in PHP
Object Relational Mapping in PHPObject Relational Mapping in PHP
Object Relational Mapping in PHPRob Knight
 
ORM: Object-relational mapping
ORM: Object-relational mappingORM: Object-relational mapping
ORM: Object-relational mappingAbhilash M A
 
JDXA, The KISS ORM for Android
JDXA, The KISS ORM for AndroidJDXA, The KISS ORM for Android
JDXA, The KISS ORM for AndroidDamodar Periwal
 
좌충우돌 ORM 개발기 | Devon 2012
좌충우돌 ORM 개발기 | Devon 2012좌충우돌 ORM 개발기 | Devon 2012
좌충우돌 ORM 개발기 | Devon 2012Daum DNA
 
About Orm.fm
About Orm.fmAbout Orm.fm
About Orm.fmOrm Moon
 
Object-Relational Mapping and Dependency Injection
Object-Relational Mapping and Dependency InjectionObject-Relational Mapping and Dependency Injection
Object-Relational Mapping and Dependency InjectionShane Church
 
Automated functional size measurement for three tier object relational mappin...
Automated functional size measurement for three tier object relational mappin...Automated functional size measurement for three tier object relational mappin...
Automated functional size measurement for three tier object relational mappin...IWSM Mensura
 
기술적 변화를 이끌어가기
기술적 변화를 이끌어가기기술적 변화를 이끌어가기
기술적 변화를 이끌어가기Jaewoo Ahn
 
SK플래닛_README_마이크로서비스 아키텍처로 개발하기
SK플래닛_README_마이크로서비스 아키텍처로 개발하기SK플래닛_README_마이크로서비스 아키텍처로 개발하기
SK플래닛_README_마이크로서비스 아키텍처로 개발하기Lee Ji Eun
 

Destaque (17)

Ling to SQL and Entity Framework performance analysis
Ling to SQL and Entity Framework performance analysisLing to SQL and Entity Framework performance analysis
Ling to SQL and Entity Framework performance analysis
 
ORM을 활용할 경우의 설계, 개발 과정
ORM을 활용할 경우의 설계, 개발 과정ORM을 활용할 경우의 설계, 개발 과정
ORM을 활용할 경우의 설계, 개발 과정
 
Object Relational Mapping In Real World Applications
Object Relational Mapping In Real World ApplicationsObject Relational Mapping In Real World Applications
Object Relational Mapping In Real World Applications
 
What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3
 
QnA blog using Django - ORM, 회원가입, 로그인/로그아웃
QnA blog using Django - ORM, 회원가입, 로그인/로그아웃QnA blog using Django - ORM, 회원가입, 로그인/로그아웃
QnA blog using Django - ORM, 회원가입, 로그인/로그아웃
 
좌충우돌 ORM 개발기 2012 DAUM DEVON
좌충우돌 ORM 개발기 2012 DAUM DEVON좌충우돌 ORM 개발기 2012 DAUM DEVON
좌충우돌 ORM 개발기 2012 DAUM DEVON
 
Object Relational Mapping in PHP
Object Relational Mapping in PHPObject Relational Mapping in PHP
Object Relational Mapping in PHP
 
ORM: Object-relational mapping
ORM: Object-relational mappingORM: Object-relational mapping
ORM: Object-relational mapping
 
JDXA, The KISS ORM for Android
JDXA, The KISS ORM for AndroidJDXA, The KISS ORM for Android
JDXA, The KISS ORM for Android
 
L16 Object Relational Mapping and NoSQL
L16 Object Relational Mapping and NoSQLL16 Object Relational Mapping and NoSQL
L16 Object Relational Mapping and NoSQL
 
좌충우돌 ORM 개발기 | Devon 2012
좌충우돌 ORM 개발기 | Devon 2012좌충우돌 ORM 개발기 | Devon 2012
좌충우돌 ORM 개발기 | Devon 2012
 
About Orm.fm
About Orm.fmAbout Orm.fm
About Orm.fm
 
Object-Relational Mapping and Dependency Injection
Object-Relational Mapping and Dependency InjectionObject-Relational Mapping and Dependency Injection
Object-Relational Mapping and Dependency Injection
 
L18 Object Relational Mapping
L18 Object Relational MappingL18 Object Relational Mapping
L18 Object Relational Mapping
 
Automated functional size measurement for three tier object relational mappin...
Automated functional size measurement for three tier object relational mappin...Automated functional size measurement for three tier object relational mappin...
Automated functional size measurement for three tier object relational mappin...
 
기술적 변화를 이끌어가기
기술적 변화를 이끌어가기기술적 변화를 이끌어가기
기술적 변화를 이끌어가기
 
SK플래닛_README_마이크로서비스 아키텍처로 개발하기
SK플래닛_README_마이크로서비스 아키텍처로 개발하기SK플래닛_README_마이크로서비스 아키텍처로 개발하기
SK플래닛_README_마이크로서비스 아키텍처로 개발하기
 

Semelhante a 03 Object Relational Mapping

Chapter 4 - Defining Your Own Classes - Part I
Chapter 4 - Defining Your Own Classes - Part IChapter 4 - Defining Your Own Classes - Part I
Chapter 4 - Defining Your Own Classes - Part IEduardo Bergavera
 
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdfSummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdfARORACOCKERY2111
 
Eclipse Day India 2011 - Extending JDT
Eclipse Day India 2011 - Extending JDTEclipse Day India 2011 - Extending JDT
Eclipse Day India 2011 - Extending JDTdeepakazad
 
#pugMi - DDD - Value objects
#pugMi - DDD - Value objects#pugMi - DDD - Value objects
#pugMi - DDD - Value objectsSimone Gentili
 
Defining classes-and-objects-1.0
Defining classes-and-objects-1.0Defining classes-and-objects-1.0
Defining classes-and-objects-1.0BG Java EE Course
 
14. Defining Classes
14. Defining Classes14. Defining Classes
14. Defining ClassesIntro C# Book
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design PatternsStefano Fago
 
CSharp presentation and software developement
CSharp presentation and software developementCSharp presentation and software developement
CSharp presentation and software developementfrwebhelp
 
Extending MySQL Enterprise Monitor
Extending MySQL Enterprise MonitorExtending MySQL Enterprise Monitor
Extending MySQL Enterprise MonitorMark Leith
 
Core2 Document - Java SCORE Overview.pptx.pdf
Core2 Document - Java SCORE Overview.pptx.pdfCore2 Document - Java SCORE Overview.pptx.pdf
Core2 Document - Java SCORE Overview.pptx.pdfThchTrngGia
 
Hibernate Mapping
Hibernate MappingHibernate Mapping
Hibernate MappingInnovationM
 
Classes, objects and methods
Classes, objects and methodsClasses, objects and methods
Classes, objects and methodsfarhan amjad
 
Introduction to Spring MVC
Introduction to Spring MVCIntroduction to Spring MVC
Introduction to Spring MVCRichard Paul
 
Preexisting code, please useMain.javapublic class Main { p.pdf
Preexisting code, please useMain.javapublic class Main {    p.pdfPreexisting code, please useMain.javapublic class Main {    p.pdf
Preexisting code, please useMain.javapublic class Main { p.pdfrd1742
 
Week9 Intro to classes and objects in Java
Week9 Intro to classes and objects in JavaWeek9 Intro to classes and objects in Java
Week9 Intro to classes and objects in Javakjkleindorfer
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with JavaJussi Pohjolainen
 

Semelhante a 03 Object Relational Mapping (20)

Chapter 4 - Defining Your Own Classes - Part I
Chapter 4 - Defining Your Own Classes - Part IChapter 4 - Defining Your Own Classes - Part I
Chapter 4 - Defining Your Own Classes - Part I
 
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdfSummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
Eclipse Day India 2011 - Extending JDT
Eclipse Day India 2011 - Extending JDTEclipse Day India 2011 - Extending JDT
Eclipse Day India 2011 - Extending JDT
 
#pugMi - DDD - Value objects
#pugMi - DDD - Value objects#pugMi - DDD - Value objects
#pugMi - DDD - Value objects
 
Defining classes-and-objects-1.0
Defining classes-and-objects-1.0Defining classes-and-objects-1.0
Defining classes-and-objects-1.0
 
14. Defining Classes
14. Defining Classes14. Defining Classes
14. Defining Classes
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design Patterns
 
CDI @javaonehyderabad
CDI @javaonehyderabadCDI @javaonehyderabad
CDI @javaonehyderabad
 
CSharp presentation and software developement
CSharp presentation and software developementCSharp presentation and software developement
CSharp presentation and software developement
 
Extending MySQL Enterprise Monitor
Extending MySQL Enterprise MonitorExtending MySQL Enterprise Monitor
Extending MySQL Enterprise Monitor
 
Core2 Document - Java SCORE Overview.pptx.pdf
Core2 Document - Java SCORE Overview.pptx.pdfCore2 Document - Java SCORE Overview.pptx.pdf
Core2 Document - Java SCORE Overview.pptx.pdf
 
Hibernate Mapping
Hibernate MappingHibernate Mapping
Hibernate Mapping
 
Classes, objects and methods
Classes, objects and methodsClasses, objects and methods
Classes, objects and methods
 
Introduction to Spring MVC
Introduction to Spring MVCIntroduction to Spring MVC
Introduction to Spring MVC
 
Preexisting code, please useMain.javapublic class Main { p.pdf
Preexisting code, please useMain.javapublic class Main {    p.pdfPreexisting code, please useMain.javapublic class Main {    p.pdf
Preexisting code, please useMain.javapublic class Main { p.pdf
 
Widget Tutorial
Widget TutorialWidget Tutorial
Widget Tutorial
 
Java Programming - 04 object oriented in java
Java Programming - 04 object oriented in javaJava Programming - 04 object oriented in java
Java Programming - 04 object oriented in java
 
Week9 Intro to classes and objects in Java
Week9 Intro to classes and objects in JavaWeek9 Intro to classes and objects in Java
Week9 Intro to classes and objects in Java
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 

Mais de Ranjan Kumar

Introduction to java ee
Introduction to java eeIntroduction to java ee
Introduction to java eeRanjan Kumar
 
Fantastic life views ons
Fantastic life views  onsFantastic life views  ons
Fantastic life views onsRanjan Kumar
 
Story does not End here
Story does not End hereStory does not End here
Story does not End hereRanjan Kumar
 
Whata Split Second Looks Like
Whata Split Second Looks LikeWhata Split Second Looks Like
Whata Split Second Looks LikeRanjan Kumar
 
Friendship so Sweet
Friendship so SweetFriendship so Sweet
Friendship so SweetRanjan Kumar
 
Dear Son Dear Daughter
Dear Son Dear DaughterDear Son Dear Daughter
Dear Son Dear DaughterRanjan Kumar
 
Alaska Railway Routes
Alaska Railway RoutesAlaska Railway Routes
Alaska Railway RoutesRanjan Kumar
 
Poison that Kills the Dreams
Poison that Kills the DreamsPoison that Kills the Dreams
Poison that Kills the DreamsRanjan Kumar
 
Best Aviation Photography
Best Aviation PhotographyBest Aviation Photography
Best Aviation PhotographyRanjan Kumar
 

Mais de Ranjan Kumar (20)

Introduction to java ee
Introduction to java eeIntroduction to java ee
Introduction to java ee
 
Fantastic life views ons
Fantastic life views  onsFantastic life views  ons
Fantastic life views ons
 
Lessons on Life
Lessons on LifeLessons on Life
Lessons on Life
 
Story does not End here
Story does not End hereStory does not End here
Story does not End here
 
Whata Split Second Looks Like
Whata Split Second Looks LikeWhata Split Second Looks Like
Whata Split Second Looks Like
 
Friendship so Sweet
Friendship so SweetFriendship so Sweet
Friendship so Sweet
 
Dedicate Time
Dedicate TimeDedicate Time
Dedicate Time
 
Paradise on Earth
Paradise on EarthParadise on Earth
Paradise on Earth
 
Bolivian Highway
Bolivian HighwayBolivian Highway
Bolivian Highway
 
Chinese Proverb
Chinese ProverbChinese Proverb
Chinese Proverb
 
Warren Buffet
Warren BuffetWarren Buffet
Warren Buffet
 
Dear Son Dear Daughter
Dear Son Dear DaughterDear Son Dear Daughter
Dear Son Dear Daughter
 
Jara Sochiye
Jara SochiyeJara Sochiye
Jara Sochiye
 
Blue Beauty
Blue BeautyBlue Beauty
Blue Beauty
 
Alaska Railway Routes
Alaska Railway RoutesAlaska Railway Routes
Alaska Railway Routes
 
Poison that Kills the Dreams
Poison that Kills the DreamsPoison that Kills the Dreams
Poison that Kills the Dreams
 
Horrible Jobs
Horrible JobsHorrible Jobs
Horrible Jobs
 
Best Aviation Photography
Best Aviation PhotographyBest Aviation Photography
Best Aviation Photography
 
Role of Attitude
Role of AttitudeRole of Attitude
Role of Attitude
 
45 Lesons in Life
45 Lesons in Life45 Lesons in Life
45 Lesons in Life
 

Último

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 

Último (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

03 Object Relational Mapping

  • 1. Object/Relational Mapping Solving the structural paradigm mismatch
  • 2.
  • 3.
  • 4.
  • 5. A simple POJO public class User implements Serializable { private String username; private Address address; public User() {} public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public Address getAddress() { return address;} public void setAddress(Address address) { this.address = address; } public MonetaryAmount calcShippingCosts(Address from) { ... } }
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27. The tables of this association mapping << table >> ITEM ITEM_ID <<PK>> NAME PRICE ... << table >> BID BID_ID <<PK>> ITEM_ID <<FK>> AMOUNT ... PRICE NAME ITEM_ID 1 2 3 Bar Foo Baz 2.00 50.00 1.00 ITEM AMOUNT ITEM_ID BID_ID 1 2 3 1 1 2 10.00 20.00 55.00 BID
  • 28.
  • 29.
  • 30.
  • 31.
  • 32. Mapping collections vs Java collections Persists an unordered,non-unique many-to-many collection using a surrogate key. java.util.List idbag Persists an indexed, non-unique collection of primitive values N/A primitive-array Persists an indexed, non-unique collection of values or objects N/A array Persists an unordered, non-unique collection of values or objects java.util.List bag Persists an ordered,non-unique collection of values or objects java.util.List list Persists a collection of key/value pairs java.util.Map map Persists an unordered,unique collection of values or objects java.util.Set set Description Java Collection Type Hibernate Collection Type
  • 33. One-to-many association <hibernate-mapping package=“demo”> <class name=“Event” table=“events”> … . <set name=“speakers”> <key column=“event_id”/> <one-to-many class=“Speaker”/> </set> <set name=“attendees”> <key column=“event_id”/> <one-to-many class=“Attendee”/> </set> … . </class> </hibernate-mapping> public class Event { private Set speakers; private set attendees; public void setSpeakers(Set speakers) { this.speakers=speakers;} public set getSpeakers() {return this.speakers;} public void setAttendees(Set attendees) { this.attendees=attendees;} public set getAttendees() {return this.attendees;}
  • 34. One-to-many events events events attendees id bigint(pk) id bigint (pk) event_id bigint (fk) A one-to-many association from events to attendees
  • 35.
  • 36. many-to-many events events events event_attendees id bigint(pk) event_id bigint (fk) attendee_id bigint (fk) A many-to-many table schema from events to attendees events events attendees id bigint(pk)
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42. idbags events events events event_attendees id bigint(pk) event_id bigint speaker_id bigint events events speakers id bigint(pk) event_speaker_id bigint (PK)
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52. Adding a property at runtime // Get the existing mapping for User from Configuration PersistentClass userMapping = cfg .getClassMapping(User.class); // Define a new column for the USER table Column column = new Column(); userMapping.getTable().addColumn(column); // Wrap the column in a Value SimpleValue value = new SimpleValue(); value.setTable( userMapping.getTable() ); value.addColumn(column); // Define a new property of the User class Property prop = new Property(); prop.setValue(value); prop.setName(&quot;motto&quot;); userMapping.addProperty(prop); // Build a new session factory, using the new mapping SessionFactory sf = cfg.buildSessionFactory();
  • 53.