Spring日志显示该表在数据库中被创建了两次,尽管数据库只显示了一组表。
这只发生在我运行mvn verify
以运行集成测试
SpringBoot 1.5.6版
这是日志
2017-08-14 13:58:00.351 INFO 36636 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2017-08-14 13:58:00.374 INFO 36636 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2017-08-14 13:58:00.467 INFO 36636 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final}
2017-08-14 13:58:00.469 INFO 36636 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2017-08-14 13:58:00.471 INFO 36636 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2017-08-14 13:58:00.629 INFO 36636 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2017-08-14 13:58:00.775 INFO 36636 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect
2017-08-14 13:58:01.418 INFO 36636 --- [ main] org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000228: Running hbm2ddl schema update
2017-08-14 13:58:01.451 INFO 36636 --- [ main] rmationExtractorJdbcDatabaseMetaDataImpl : HHH000262: Table not found: album
2017-08-14 13:58:01.454 INFO 36636 --- [ main] rmationExtractorJdbcDatabaseMetaDataImpl : HHH000262: Table not found: album
2017-08-14 13:58:01.463 INFO 36636 --- [ main] rmationExtractorJdbcDatabaseMetaDataImpl : HHH000262: Table not found: album_image_set
2017-08-14 13:58:01.465 INFO 36636 --- [ main] rmationExtractorJdbcDatabaseMetaDataImpl : HHH000262: Table not found: album_image_set
...
2017-08-14 13:58:01.658 INFO 36636 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
application.properties
spring.datasource.url = jdbc:hsqldb:mem:manudcamera_api_sandbox
spring.datasource.username = sa
spring.datasource.password =
spring.datasource.driver-class-name = org.hsqldb.jdbcDriver
spring.jpa.hibernate.ddl-auto = update
spring.jpa.show-sql = false
示例实体类,省略了setter / getter。 AbstractEntity Class
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class AbstractEntity implements Serializable {
@Id
@GeneratedValue
private Long id;
@CreatedDate
private Date createdDate;
@LastModifiedDate
private Date lastModifiedDate;
@Override
public abstract int hashCode();
@Override
public abstract boolean equals(Object obj);
}
相册
@Entity
public class Album extends AbstractEntity {
@Column(nullable = false)
private String uuid;
@Column(nullable = false)
private String name;
@OneToMany(cascade = {CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.REFRESH}, orphanRemoval = true)
private Set<Image> imageSet = new HashSet<>(0);
}