Made the webapp launch, but some of the forms fail - need to investigate

This commit is contained in:
anbu 2021-01-31 04:16:39 +00:00
parent 2aa3e9df9c
commit aa6172bfec
16 changed files with 291 additions and 234 deletions

View file

@ -58,6 +58,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>

View file

@ -1,51 +1,9 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.model;
import java.io.Serializable;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
public interface BaseEntity {
Integer getId();
/**
* Simple JavaBean domain object with an id property. Used as a base class for objects
* needing this property.
*
* @author Ken Krebs
* @author Juergen Hoeller
*/
@MappedSuperclass
public class BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
public Integer getId() {
return id;
default boolean isNew() {
return getId() == null;
}
public void setId(Integer id) {
this.id = id;
}
public boolean isNew() {
return this.id == null;
}
}

View file

@ -16,9 +16,6 @@
package org.springframework.samples.petclinic.model;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
/**
* Simple JavaBean domain object adds a name property to <code>BaseEntity</code>. Used as
* a base class for objects needing these properties.
@ -26,23 +23,7 @@ import javax.persistence.MappedSuperclass;
* @author Ken Krebs
* @author Juergen Hoeller
*/
@MappedSuperclass
public class NamedEntity extends BaseEntity {
@Column(name = "name")
private String name;
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return this.getName();
}
public interface NamedEntity extends BaseEntity {
String getName();
}

View file

@ -17,8 +17,12 @@
package org.springframework.samples.petclinic.model;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotEmpty;
import lombok.Data;
/**
* Simple JavaBean domain object representing an person.
@ -26,7 +30,11 @@ import javax.validation.constraints.NotEmpty;
* @author Ken Krebs
*/
@MappedSuperclass
public class Person extends BaseEntity {
@Data
public class Person implements BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@Column(name = "first_name")
@NotEmpty
@ -36,20 +44,4 @@ public class Person extends BaseEntity {
@NotEmpty
private String lastName;
public String getFirstName() {
return this.firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return this.lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}

View file

@ -24,13 +24,19 @@ import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotEmpty;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.support.MutableSortDefinition;
import org.springframework.beans.support.PropertyComparator;
import org.springframework.core.style.ToStringCreator;
import org.springframework.samples.petclinic.model.BaseEntity;
import org.springframework.samples.petclinic.model.Person;
/**
@ -43,7 +49,12 @@ import org.springframework.samples.petclinic.model.Person;
*/
@Entity
@Table(name = "owners")
public class Owner extends Person {
@Data
@NoArgsConstructor
public class Owner extends Person implements BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@Column(name = "address")
@NotEmpty
@ -61,28 +72,15 @@ public class Owner extends Person {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
private Set<Pet> pets;
public String getAddress() {
return this.address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCity() {
return this.city;
}
public void setCity(String city) {
this.city = city;
}
public String getTelephone() {
return this.telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
/**
* all args constructor.
*/
public Owner(String firstName, String lastName, String address, String city, String telephone) {
this.setFirstName(firstName);
this.setLastName(lastName);
this.setAddress(address);
this.setCity(city);
this.setTelephone(telephone);
}
protected Set<Pet> getPetsInternal() {

View file

@ -26,14 +26,18 @@ import java.util.List;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import lombok.Data;
import org.springframework.beans.support.MutableSortDefinition;
import org.springframework.beans.support.PropertyComparator;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.samples.petclinic.model.NamedEntity;
import org.springframework.samples.petclinic.model.BaseEntity;
import org.springframework.samples.petclinic.visit.Visit;
/**
@ -45,7 +49,14 @@ import org.springframework.samples.petclinic.visit.Visit;
*/
@Entity
@Table(name = "pets")
public class Pet extends NamedEntity {
@Data
public class Pet implements BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@Column(name = "name")
private String name;
@Column(name = "birth_date")
@DateTimeFormat(pattern = "yyyy-MM-dd")

View file

@ -16,8 +16,15 @@
package org.springframework.samples.petclinic.owner;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.samples.petclinic.model.NamedEntity;
/**
@ -27,6 +34,13 @@ import org.springframework.samples.petclinic.model.NamedEntity;
*/
@Entity
@Table(name = "types")
public class PetType extends NamedEntity {
@Data
public class PetType implements NamedEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@Column(name = "name")
private String name;
}

View file

@ -0,0 +1,96 @@
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.system;
import java.util.stream.Stream;
import javax.annotation.PostConstruct;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.samples.petclinic.owner.Owner;
import org.springframework.samples.petclinic.owner.PetType;
import org.springframework.samples.petclinic.vet.Specialty;
import org.springframework.samples.petclinic.vet.Vet;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@Component
@Slf4j
@Transactional
class InitData {
private final EntityManagerFactory emf;
@Autowired
public InitData(EntityManagerFactory emf) {
this.emf = emf;
}
@PostConstruct
public void registerListeners() {
SessionFactory sessionFactory = emf.unwrap(SessionFactory.class);
EntityManager em = sessionFactory.createEntityManager();
createPetTypes(em);
createOwners(em);
createVets(em);
createSpecialities(em);
}
private void createPetTypes(EntityManager em) {
em.getTransaction().begin();
Stream.of("cat", "dog", "lizard", "snake", "bird", "hamster").forEach(v -> {
PetType petType = new PetType();
em.persist(petType);
});
em.getTransaction().commit();
}
private void createSpecialities(EntityManager em) {
em.getTransaction().begin();
Stream.of("radiology", "surgery", "dentistry").forEach(name -> em.persist(new Specialty(name)));
em.getTransaction().commit();
}
private void createVets(EntityManager em) {
em.getTransaction().begin();
em.persist(new Vet("James", "Carter"));
em.persist(new Vet("Helen", "Leary"));
em.persist(new Vet("Linda", "Douglas"));
em.persist(new Vet("Rafael", "Ortega"));
em.persist(new Vet("Henry", "Stevens"));
em.persist(new Vet("Sharon", "Jenkins"));
em.getTransaction().commit();
}
private void createOwners(EntityManager em) {
em.getTransaction().begin();
em.persist(new Owner("George", "Franklin", "110 W. Liberty St.", "Madison", "6085551023"));
em.persist(new Owner("Betty", "Davis", "638 Cardinal Ave.", "Sun Prairie", "6085551749"));
em.persist(new Owner("Eduardo", "Rodriquez", "2693 Commerce St.", "McFarland", "6085558763"));
em.persist(new Owner("Harold", "Davis", "563 Friendly St.", "Windsor", "6085553198"));
em.persist(new Owner("Peter", "McTavish", "2387 S. Fair Way", "Madison", "6085552765"));
em.persist(new Owner("Jean", "Coleman", "105 N. Lake St.", "Monona", "6085552654"));
em.persist(new Owner("Jeff", "Black", "1450 Oak Blvd.", "Monona", "6085555387"));
em.persist(new Owner("Maria", "Escobito", "345 Maple St.", "Madison", "6085557683"));
em.persist(new Owner("David", "Schroeder", "2749 Blackhawk Trail", "Madison", "6085559435"));
em.persist(new Owner("Carlos", "Estaban", "2335 Independence La.", "Waunakee", "6085555487"));
em.getTransaction().commit();
}
}

View file

@ -17,8 +17,14 @@
package org.springframework.samples.petclinic.vet;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.samples.petclinic.model.NamedEntity;
/**
@ -28,6 +34,18 @@ import org.springframework.samples.petclinic.model.NamedEntity;
*/
@Entity
@Table(name = "specialties")
public class Specialty extends NamedEntity implements Serializable {
@Data
@NoArgsConstructor
public class Specialty implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@Column(name = "name")
private String name;
public Specialty(String name) {
this.setName(name);
}
}

View file

@ -28,6 +28,7 @@ import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlElement;
import lombok.NoArgsConstructor;
import org.springframework.beans.support.MutableSortDefinition;
import org.springframework.beans.support.PropertyComparator;
import org.springframework.samples.petclinic.model.Person;
@ -42,8 +43,14 @@ import org.springframework.samples.petclinic.model.Person;
*/
@Entity
@Table(name = "vets")
@NoArgsConstructor
public class Vet extends Person {
public Vet(String firstName, String lastName) {
this.setFirstName(firstName);
this.setLastName(lastName);
}
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "vet_specialties", joinColumns = @JoinColumn(name = "vet_id"),
inverseJoinColumns = @JoinColumn(name = "specialty_id"))

View file

@ -16,13 +16,17 @@
package org.springframework.samples.petclinic.visit;
import java.io.Serializable;
import java.time.LocalDate;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotEmpty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.samples.petclinic.model.BaseEntity;
/**
* Simple JavaBean domain object representing a visit.
@ -32,7 +36,11 @@ import org.springframework.samples.petclinic.model.BaseEntity;
*/
@Entity
@Table(name = "visits")
public class Visit extends BaseEntity {
@Data
public class Visit implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@Column(name = "visit_date")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@ -51,29 +59,4 @@ public class Visit extends BaseEntity {
public Visit() {
this.date = LocalDate.now();
}
public LocalDate getDate() {
return this.date;
}
public void setDate(LocalDate date) {
this.date = date;
}
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getPetId() {
return this.petId;
}
public void setPetId(Integer petId) {
this.petId = petId;
}
}

View file

@ -19,7 +19,6 @@ package org.springframework.samples.petclinic.visit;
import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.data.repository.Repository;
import org.springframework.samples.petclinic.model.BaseEntity;
/**
* Repository class for <code>Visit</code> domain objects All method names are compliant

View file

@ -2,15 +2,17 @@
database: h2
spring:
datasource:
schema: classpath*:db/${database}/schema.sql
# schema: classpath*:db/${database}/schema.sql
data: classpath*:db/${database}/data.sql
jpa:
hibernate.ddl-auto: none
open-in-view: false
spring.thymeleaf.mode: HTML
# Internationalization
spring.messages.basename: messages/messages
liquibase:
enabled: true
change-log: classpath*:db/db-changelog.yaml
thymeleaf.mode: HTML
# Internationalization
messages.basename: messages/messages
# Actuator
management.endpoints.web.exposure.include: '*'

View file

@ -1,13 +1,13 @@
INSERT INTO vets VALUES (1, 'James', 'Carter');
INSERT INTO vets VALUES (2, 'Helen', 'Leary');
INSERT INTO vets VALUES (3, 'Linda', 'Douglas');
INSERT INTO vets VALUES (4, 'Rafael', 'Ortega');
INSERT INTO vets VALUES (5, 'Henry', 'Stevens');
INSERT INTO vets VALUES (6, 'Sharon', 'Jenkins');
-- INSERT INTO vets VALUES (1, 'James', 'Carter');
-- INSERT INTO vets VALUES (2, 'Helen', 'Leary');
-- INSERT INTO vets VALUES (3, 'Linda', 'Douglas');
-- INSERT INTO vets VALUES (4, 'Rafael', 'Ortega');
-- INSERT INTO vets VALUES (5, 'Henry', 'Stevens');
-- INSERT INTO vets VALUES (6, 'Sharon', 'Jenkins');
INSERT INTO specialties VALUES (1, 'radiology');
INSERT INTO specialties VALUES (2, 'surgery');
INSERT INTO specialties VALUES (3, 'dentistry');
-- INSERT INTO specialties VALUES (1, 'radiology');
-- INSERT INTO specialties VALUES (2, 'surgery');
-- INSERT INTO specialties VALUES (3, 'dentistry');
INSERT INTO vet_specialties VALUES (2, 1);
INSERT INTO vet_specialties VALUES (3, 2);
@ -15,23 +15,16 @@ INSERT INTO vet_specialties VALUES (3, 3);
INSERT INTO vet_specialties VALUES (4, 2);
INSERT INTO vet_specialties VALUES (5, 1);
INSERT INTO types VALUES (1, 'cat');
INSERT INTO types VALUES (2, 'dog');
INSERT INTO types VALUES (3, 'lizard');
INSERT INTO types VALUES (4, 'snake');
INSERT INTO types VALUES (5, 'bird');
INSERT INTO types VALUES (6, 'hamster');
INSERT INTO owners VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023');
INSERT INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749');
INSERT INTO owners VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763');
INSERT INTO owners VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198');
INSERT INTO owners VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765');
INSERT INTO owners VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654');
INSERT INTO owners VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387');
INSERT INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683');
INSERT INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435');
INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487');
-- INSERT INTO owners VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023');
-- INSERT INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749');
-- INSERT INTO owners VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763');
-- INSERT INTO owners VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198');
-- INSERT INTO owners VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765');
-- INSERT INTO owners VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654');
-- INSERT INTO owners VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387');
-- INSERT INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683');
-- INSERT INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435');
-- INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487');
INSERT INTO pets VALUES (1, 'Leo', '2010-09-07', 1, 1);
INSERT INTO pets VALUES (2, 'Basil', '2012-08-06', 6, 2);

View file

@ -1,64 +1,65 @@
DROP TABLE vet_specialties IF EXISTS;
DROP TABLE vets IF EXISTS;
DROP TABLE specialties IF EXISTS;
DROP TABLE visits IF EXISTS;
DROP TABLE pets IF EXISTS;
DROP TABLE types IF EXISTS;
DROP TABLE owners IF EXISTS;
-- DROP TABLE vet_specialties IF EXISTS;
-- DROP TABLE vets IF EXISTS;
-- DROP TABLE specialties IF EXISTS;
-- DROP TABLE visits IF EXISTS;
-- DROP TABLE pets IF EXISTS;
-- DROP TABLE types IF EXISTS;
-- DROP TABLE owners IF EXISTS;
--
--
-- CREATE TABLE vets (
-- id INTEGER IDENTITY PRIMARY KEY,
-- first_name VARCHAR(30),
-- last_name VARCHAR(30)
-- );
-- CREATE INDEX vets_last_name ON vets (last_name);
--
-- CREATE TABLE specialties (
-- id INTEGER IDENTITY PRIMARY KEY,
-- name VARCHAR(80)
-- );
-- CREATE INDEX specialties_name ON specialties (name);
--
-- CREATE TABLE vet_specialties (
-- vet_id INTEGER NOT NULL,
-- specialty_id INTEGER NOT NULL
-- );
-- ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_vets FOREIGN KEY (vet_id) REFERENCES vets (id);
-- ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_specialties FOREIGN KEY (specialty_id) REFERENCES specialties (id);
--
-- CREATE TABLE types (
-- id INTEGER IDENTITY PRIMARY KEY,
-- name VARCHAR(80)
-- );
-- CREATE INDEX types_name ON types (name);
--
-- CREATE TABLE owners (
-- id INTEGER IDENTITY PRIMARY KEY,
-- first_name VARCHAR(30),
-- last_name VARCHAR_IGNORECASE(30),
-- address VARCHAR(255),
-- city VARCHAR(80),
-- telephone VARCHAR(20)
-- );
-- CREATE INDEX owners_last_name ON owners (last_name);
--
-- CREATE TABLE pets (
-- id INTEGER IDENTITY PRIMARY KEY,
-- name VARCHAR(30),
-- birth_date DATE,
-- type_id INTEGER NOT NULL,
-- owner_id INTEGER NOT NULL
-- );
-- ALTER TABLE pets ADD CONSTRAINT fk_pets_owners FOREIGN KEY (owner_id) REFERENCES owners (id);
-- ALTER TABLE pets ADD CONSTRAINT fk_pets_types FOREIGN KEY (type_id) REFERENCES types (id);
-- CREATE INDEX pets_name ON pets (name);
--
-- CREATE TABLE visits (
-- id INTEGER IDENTITY PRIMARY KEY,
-- pet_id INTEGER NOT NULL,
-- visit_date DATE,
-- description VARCHAR(255)
-- );
-- ALTER TABLE visits ADD CONSTRAINT fk_visits_pets FOREIGN KEY (pet_id) REFERENCES pets (id);
-- CREATE INDEX visits_pet_id ON visits (pet_id);
CREATE TABLE vets (
id INTEGER IDENTITY PRIMARY KEY,
first_name VARCHAR(30),
last_name VARCHAR(30)
);
CREATE INDEX vets_last_name ON vets (last_name);
CREATE TABLE specialties (
id INTEGER IDENTITY PRIMARY KEY,
name VARCHAR(80)
);
CREATE INDEX specialties_name ON specialties (name);
CREATE TABLE vet_specialties (
vet_id INTEGER NOT NULL,
specialty_id INTEGER NOT NULL
);
ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_vets FOREIGN KEY (vet_id) REFERENCES vets (id);
ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_specialties FOREIGN KEY (specialty_id) REFERENCES specialties (id);
CREATE TABLE types (
id INTEGER IDENTITY PRIMARY KEY,
name VARCHAR(80)
);
CREATE INDEX types_name ON types (name);
CREATE TABLE owners (
id INTEGER IDENTITY PRIMARY KEY,
first_name VARCHAR(30),
last_name VARCHAR_IGNORECASE(30),
address VARCHAR(255),
city VARCHAR(80),
telephone VARCHAR(20)
);
CREATE INDEX owners_last_name ON owners (last_name);
CREATE TABLE pets (
id INTEGER IDENTITY PRIMARY KEY,
name VARCHAR(30),
birth_date DATE,
type_id INTEGER NOT NULL,
owner_id INTEGER NOT NULL
);
ALTER TABLE pets ADD CONSTRAINT fk_pets_owners FOREIGN KEY (owner_id) REFERENCES owners (id);
ALTER TABLE pets ADD CONSTRAINT fk_pets_types FOREIGN KEY (type_id) REFERENCES types (id);
CREATE INDEX pets_name ON pets (name);
CREATE TABLE visits (
id INTEGER IDENTITY PRIMARY KEY,
pet_id INTEGER NOT NULL,
visit_date DATE,
description VARCHAR(255)
);
ALTER TABLE visits ADD CONSTRAINT fk_visits_pets FOREIGN KEY (pet_id) REFERENCES pets (id);
CREATE INDEX visits_pet_id ON visits (pet_id);

View file

@ -16,6 +16,7 @@
package org.springframework.samples.petclinic.service;
import java.io.Serializable;
import java.util.Collection;
import org.springframework.orm.ObjectRetrievalFailureException;
@ -27,7 +28,6 @@ import org.springframework.samples.petclinic.model.BaseEntity;
*
* @author Juergen Hoeller
* @author Sam Brannen
* @see org.springframework.samples.petclinic.model.BaseEntity
* @since 29.10.2003
*/
public abstract class EntityUtils {