Презентация 3. Java Persistence API. 4. Entity Relationships онлайн
На нашем сайте вы можете скачать и просмотреть онлайн доклад-презентацию на тему 3. Java Persistence API. 4. Entity Relationships абсолютно бесплатно. Урок-презентация на эту тему содержит всего 43 слайда. Все материалы созданы в программе PowerPoint и имеют формат ppt или же pptx. Материалы и темы для презентаций взяты из открытых источников и загружены их авторами, за качество и достоверность информации в них администрация сайта не отвечает, все права принадлежат их создателям. Если вы нашли то, что искали, отблагодарите авторов - поделитесь ссылкой в социальных сетях, а наш сайт добавьте в закладки.
Презентации » Устройства и комплектующие » 3. Java Persistence API. 4. Entity Relationships
Оцените!
Оцените презентацию от 1 до 5 баллов!
- Тип файла:ppt / pptx (powerpoint)
- Всего слайдов:43 слайда
- Для класса:1,2,3,4,5,6,7,8,9,10,11
- Размер файла:287.00 kB
- Просмотров:50
- Скачиваний:0
- Автор:неизвестен
Слайды и текст к этой презентации:
№2 слайд
![Basics A foreign key can be](/documents_6/9cfb44c2736edaa1a1d9d26925789578/img1.jpg)
Содержание слайда: Basics
A foreign key can be one or more columns that reference a unique key, usually the primary key, in another table
A foreign key and the primary parent key it references must have the same number and type of fields
Foreign keys represents relationships from a column or columns in one table to a column or columns in another table
№3 слайд
![Multiplicity in Entity](/documents_6/9cfb44c2736edaa1a1d9d26925789578/img2.jpg)
Содержание слайда: Multiplicity in Entity Relationships
Multiplicities are of the following types:
Many-to-one: Multiple instances of an entity can be related to a single instance of the other entity
One-to-one: Each entity instance is related to a single instance of another entity
One-to-many: An entity instance can be related to multiple instances of the other entities
Many-to-many: The entity instances can be related to multiple instances of each other.
№8 слайд
![Payment Entity of Entity](/documents_6/9cfb44c2736edaa1a1d9d26925789578/img7.jpg)
Содержание слайда: Payment Entity (1 of 2)
@Entity
public class Payment {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
private double charge;
private double total;
private String goods;
private java.sql.Date dt;
@ManyToOne
@JoinColumn(name="merchantId")
private Merchant merchant;
№9 слайд
![Payment Entity of public](/documents_6/9cfb44c2736edaa1a1d9d26925789578/img8.jpg)
Содержание слайда: Payment Entity (2 of 2)
public Merchant getMerchant(){ return merchant; }
public void setMerchant(Merchant value){
merchant = value;
}
. . . . . . . . . . . . . . . .
public String getStringForPrint() {
String txt = "id = " + id + "; date = ";
SimpleDateFormat dtFrm = new SimpleDateFormat("dd.MM.yyyy");
txt += dtFrm.format(dt) + "; merchant = " + merchant.getName();
txt += "; total = " + total + "; charge = " + charge;
return txt;
}
№10 слайд
![DAO amp Service Interfaces](/documents_6/9cfb44c2736edaa1a1d9d26925789578/img9.jpg)
Содержание слайда: DAO & Service Interfaces
public interface PaymentDao {
public List<Payment> findByMerchantId(int id);
public double getPaymentSum();
public Payment findById(int id);
}
public interface PaymentService {
public List<Payment> findByMerchantId(int id);
public double getPaymentSum();
public Payment findById(int id);
}
№12 слайд
![Main Class SuppressWarnings](/documents_6/9cfb44c2736edaa1a1d9d26925789578/img11.jpg)
Содержание слайда: Main Class
@SuppressWarnings("resource")
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
PaymentService paymentService = context.getBean(PaymentService.class);
Payment p = paymentService.findById(2);
System.out.println(p.toString());
}
№15 слайд
![PaymentDaoImp Class public](/documents_6/9cfb44c2736edaa1a1d9d26925789578/img14.jpg)
Содержание слайда: PaymentDaoImp Class
public List<Result> getTotalReport(){
String txt = "SELECT new com.bionic.edu.Result
(p.merchant.name, count(p), SUM(p.chargePayed))";
txt += "FROM Payment p GROUP BY p.merchant.name";
TypedQuery<Result> query = em.createQuery(txt, Result.class);
return query.getResultList();
}
№16 слайд
![Main Class SuppressWarnings](/documents_6/9cfb44c2736edaa1a1d9d26925789578/img15.jpg)
Содержание слайда: Main Class
@SuppressWarnings("resource")
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
PaymentService paymentService = context.getBean(PaymentService.class);
List<Result> list = paymentService.getTotalReport();
for(Result r: list)
System.out.format("%1$25s %2$3d %3$8.2f \n", r.getName(), r.getCount(), r.getSum());
}
№18 слайд
![One-to-Many Mappings An](/documents_6/9cfb44c2736edaa1a1d9d26925789578/img17.jpg)
Содержание слайда: One-to-Many Mappings
An entity instance can be related to multiple instances of the other entities
One-to-many relationships use the @OneToMany annotation on the corresponding persistent property or field
The mappedBy element is needed to refer to the attribute annotated by ManyToOne in the corresponding entity:
@OneToMany(mappedBy=“attribute”)
A one-to-many association needs to map the collection of entities
№21 слайд
![Merchant Entity Entity public](/documents_6/9cfb44c2736edaa1a1d9d26925789578/img20.jpg)
Содержание слайда: Merchant Entity
@Entity
public class Merchant {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
private String name;
private double charge;
private int period;
private double total;
@OneToMany(mappedBy="merchant")
private Collection<Payment> payments;
№22 слайд
![Main Class of](/documents_6/9cfb44c2736edaa1a1d9d26925789578/img21.jpg)
Содержание слайда: Main Class (1 of 2)
@SuppressWarnings("resource")
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
MerchantService merchantService = context.getBean(MerchantService.class);
List<Merchant> list = merchantService.getSortedByNeedToPay();
for(Merchant m: list){
System.out.println("=======================");
System.out.println(m.getName());
№25 слайд
![Many-to-Many Mappings The](/documents_6/9cfb44c2736edaa1a1d9d26925789578/img24.jpg)
Содержание слайда: Many-to-Many Mappings
The entity instances can be related to multiple instances of each other
Many-to-many relationships use the @ManyToMany annotation on the corresponding persistent property or field
We must use a third table to associate the two entity types (join table)
№30 слайд
![Main Class SuppressWarnings](/documents_6/9cfb44c2736edaa1a1d9d26925789578/img29.jpg)
Содержание слайда: Main Class
@SuppressWarnings("resource")
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
CustomerService customerService = context.getBean(CustomerService.class);
Customer customer = customerService.findById(1);
if (customer != null){
System.out.println(customer.toString());
Collection<Merchant> merchants = customer.getMerchants();
for (Merchant m : merchants) { System.out.println(m.getName());}}}
№34 слайд
![Embedded Objects of An](/documents_6/9cfb44c2736edaa1a1d9d26925789578/img33.jpg)
Содержание слайда: Embedded Objects (1 of 2)
An embedded object is one that is dependent on an entity for its identity
It has no identity of its own, but is merely part of the entity state
The state of the embedded object is stored with the rest of the entity state in the database row, with no distinction between the state in the Java entity and that in its embedded object
№36 слайд
![Embedded Type An embedded](/documents_6/9cfb44c2736edaa1a1d9d26925789578/img35.jpg)
Содержание слайда: Embedded Type
An embedded type is marked as such by adding the @Embeddable annotation to the class definition
Its fields and properties will be persistable as part of an entity
We might also want to define the access type of the embeddable object so it is accessed the same way regardless of which entity it is embedded in
№40 слайд
![Database Schema Generation](/documents_6/9cfb44c2736edaa1a1d9d26925789578/img39.jpg)
Содержание слайда: Database Schema Generation
Automatically generation the tables and database schema for a persistence unit can be done through the "eclipselink.ddl-generation" persistence unit property
The tables and constraints will be generated for all of the classes defined in that persistence unit.
№41 слайд
![eclipselink.ddl-generation](/documents_6/9cfb44c2736edaa1a1d9d26925789578/img40.jpg)
Содержание слайда: eclipselink.ddl-generation Values
create-tables – if the table already exists then it will not be dropped or replaced, the existing table will be used
drop-and-create-tables - will first drop the existing table, and then create the new table. Note that this will lose all of the data in the tables when they are dropped!!
№42 слайд
![Schema Generation Practice](/documents_6/9cfb44c2736edaa1a1d9d26925789578/img41.jpg)
Содержание слайда: Schema Generation Practice
One of the complaints around schema generation is that you can’t specify everything that you need to be able to finely tune the schema.
There are too many differences between databases and too many different settings to try to put in options for every database type.
№43 слайд
![Schema Generation Practice If](/documents_6/9cfb44c2736edaa1a1d9d26925789578/img42.jpg)
Содержание слайда: Schema Generation Practice
If every database-tuning option were exposed through JPA then we would end up duplicating the features of Data Definition Language (DDL) in an API
The final schema will typically be tuned by a database administrator or someone with the appropriate level of database experience.
Скачать все slide презентации 3. Java Persistence API. 4. Entity Relationships одним архивом:
Похожие презентации
-
3. Java Persistence API. 5. Transaction Management
-
3. Java Persistence API. 4. Java Persistence Query Language
-
Java 8 Stream API
-
JDBC стандартный прикладной интерфейс (API) языка Java. (Лекция 16)
-
Java Sound API
-
ИТ инициатива Java 8
-
JavaScript. Занятие 18
-
Java 4 WEB. Lesson 10 - IO, NIO
-
Создание программных приложений на базе технологии Entity Framework
-
Основы программирование: Введение в Java. Коллекции