--- /dev/null
+create sequence hibernate_sequence start with 1 increment by 1;
+
+ create table MyEntity (
+ id integer not null,
+ status blob,
+ primary key (id)
+ );
<artifactId>h2</artifactId>
<version>1.3.168</version>
</dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.11</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.1.0.Final</version>
</dependency>
-
</dependencies>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
+ <plugin>
+ <groupId>de.juplo</groupId>
+ <artifactId>hibernate-maven-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <execute>false</execute>
+ <format>true</format>
+ <scanTestClasses>true</scanTestClasses>
+ </configuration>
+ <executions>
+ <execution>
+ <id>create</id>
+ <goals>
+ <goal>create</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
--- /dev/null
+package io.blep;
+
+import javax.persistence.*;
+
+/**
+ * @author blep
+ */
+@Entity
+public class MyEntity {
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Integer id;
+
+ @Convert(converter = MyConverter.class)
+ @Lob
+ private String status;
+
+ @Converter
+ public static class MyConverter implements AttributeConverter<String, Integer> {
+
+ @Override
+ public Integer convertToDatabaseColumn(String attribute) {
+ return attribute == null ? 0 : attribute.length();
+ }
+
+ @Override
+ public String convertToEntityAttribute(Integer dbData) {
+ return "";
+ }
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" version="2.1">
+
+ <persistence-unit name="samplePU" transaction-type="RESOURCE_LOCAL">
+ <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
+ <class>io.blep.MyEntity</class>
+ <properties>
+ <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
+ <property name="javax.persistence.schema-generation.scripts.drop-target" value="sampleDrop.ddl"/>
+ <property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
+ <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:sampleDB"/>
+ </properties>
+ </persistence-unit>
+</persistence>
+++ /dev/null
-package io.blep;
-
-import org.junit.Test;
-
-import javax.persistence.*;
-
-/**
- * @author blep
- */
-public class LobConverterTest {
-
- @Test
- public void testName() throws Exception {
- final EntityManagerFactory emf = Persistence.createEntityManagerFactory("samplePU");
-
- final EntityManager em = emf.createEntityManager();
-
- em.getTransaction().begin();
- em.persist(new MyEntity());
- em.getTransaction().commit();
- }
-}
+++ /dev/null
-package io.blep;
-
-import javax.persistence.*;
-
-/**
- * @author blep
- */
-@Entity
-public class MyEntity {
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- private Integer id;
-
- @Convert(converter = MyConverter.class)
- @Lob
- private String status;
-
- @Converter
- public static class MyConverter implements AttributeConverter<String, Integer> {
-
- @Override
- public Integer convertToDatabaseColumn(String attribute) {
- return attribute == null ? 0 : attribute.length();
- }
-
- @Override
- public String convertToEntityAttribute(Integer dbData) {
- return "";
- }
- }
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" version="2.1">
-
- <persistence-unit name="samplePU" transaction-type="RESOURCE_LOCAL">
- <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
- <class>io.blep.MyEntity</class>
- <properties>
- <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
- <property name="javax.persistence.schema-generation.scripts.drop-target" value="sampleDrop.ddl"/>
- <property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
- <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:sampleDB"/>
- </properties>
- </persistence-unit>
-</persistence>
--- /dev/null
+import de.juplo.test.FileComparator;
+
+
+FileComparator comparator = new FileComparator(basedir);
+
+if (!comparator.isEqual("create.sql","target/create.sql"))
+ return false;
MojoFailureException
{
- String driver = (String)
- (properties.containsKey(DRIVER)
- ? properties.getProperty(DRIVER)
- : properties.getProperty(JDBC_DRIVER)
- );
- String url = (String)
- (properties.containsKey(URL)
- ? properties.getProperty(URL)
- : properties.getProperty(JDBC_URL)
- );
- String user = (String)
- (properties.containsKey(USER)
- ? properties.getProperty(USER)
- : properties.getProperty(JDBC_USER)
- );
- String password = (String)
- (properties.containsKey(PASS)
- ? properties.getProperty(PASS)
- : properties.getProperty(JDBC_PASSWORD)
- );
-
- if (driver == null || url == null || user == null)
+ String driver = (String)properties.getProperty(DRIVER);
+ String url = (String)properties.getProperty(URL);
+ String user = (String)properties.getProperty(USER);
+ String password = (String)properties.getProperty(PASS);
+
+ if (driver == null || url == null)
{
log.info("No connection opened, because connection information is incomplete");
log.info("Driver-Class: " + driver);
log.info("URL: " + url);
- log.info("User: " + user);
return;
}
.registerDriver(new DriverProxy((Driver) driverClass.newInstance()));
log.debug(
- "Opening JDBC-connection to " + properties.getProperty(URL) +
- " as " + properties.getProperty(USERNAME) +
- " with password " + properties.getProperty(PASSWORD)
+ "Opening JDBC-connection to " + url +
+ " as " + user +
+ " with password " + password
);
connection = DriverManager.getConnection(url, user, password);
}
catch (Exception e)
{
- throw new MojoFailureException("Could not open the JDBC-connection", e);
+ log.info("Could not open the JDBC-connection: " + e.getMessage());
}
}