spring - SpringMVC Hibernate + SQLite not creating database -


i trying use hibernate , sqlite in spring mvc project, have configurated project , when run on server, database not created , can't connect or use sqlite database.

there no exception wthen server start , i'm using entity manager hibernate4.

persistence.xml

<?xml version="1.0" encoding="utf-8"?>  <beans xmlns="http://www.springframework.org/schema/beans"  	xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:p="http://www.springframework.org/schema/p"  	xmlns:jee="http://www.springframework.org/schema/jee" xmlns:util="http://www.springframework.org/schema/util"  	xmlns:tx="http://www.springframework.org/schema/tx"  	xmlns:jdbc="http://www.springframework.org/schema/jdbc"  	xsi:schemalocation="http://www.springframework.org/schema/beans   	http://www.springframework.org/schema/beans/spring-beans.xsd  	 http://www.springframework.org/schema/jee   	 http://www.springframework.org/schema/jee/spring-jee.xsd   	 http://www.springframework.org/schema/util   	 http://www.springframework.org/schema/util/spring-util.xsd  	  http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd  	  http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">    	<!-- load database property file -->    	<bean  		class="org.springframework.beans.factory.config.propertyplaceholderconfigurer">  		<property name="location">  			<value>classpath:database.properties</value>  		</property>  	</bean>    	<!-- create datasource bean -->    	<bean id="datasource"  		class="org.springframework.jdbc.datasource.drivermanagerdatasource">  		<property name="driverclassname" value="org.sqlite.jdbc" />  		<property name="url" value="jdbc:sqlite:franchise.db" />  		<property name="username" value="" />  		<property name="password" value="" />  	</bean>      	<!-- create entity manager - jpa -->    	<bean id="entitymanagerfactory"  		class="org.springframework.orm.jpa.localcontainerentitymanagerfactorybean">  		<property name="datasource" ref="datasource" />  		<property name="packagestoscan" value="com.binov.franchise.model.*" />    		<property name="jpavendoradapter">  			<bean class="org.springframework.orm.jpa.vendor.hibernatejpavendoradapter" />  		</property>    		<property name="jpaproperties">  			<props>  				<prop key="hibernate.hbm2ddl.auto">create-drop</prop>  				<prop key="hibernate.dialect">org.hibernate.dialect.sqlitedialect</prop>  				<prop key="hibernate.show_sql">true</prop>  			</props>  		</property>    	</bean>       <tx:annotation-driven />    	<bean id="transactionmanager" class="org.springframework.orm.jpa.jpatransactionmanager">  		<property name="entitymanagerfactory" ref="entitymanagerfactory" />  	</bean>    <tx:annotation-driven transaction-manager="transactionmanager"/>  	<tx:annotation-driven />    </beans>	

pom.xml        <?xml version="1.0" encoding="utf-8"?>      <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"      	xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">      	<modelversion>4.0.0</modelversion>      	<groupid>com.binov</groupid>      	<artifactid>franchise</artifactid>      	<name>projectfranchise</name>      	<packaging>war</packaging>      	<version>1.0.0-build-snapshot</version>      	<properties>      		<project.build.sourceencoding>utf-8</project.build.sourceencoding>        		<jdk.version>1.7</jdk.version>        		<jackson-version>1.9.13</jackson-version>        		<org.slf4j-version>1.6.6</org.slf4j-version>        		<!-- <iresolve-core.mysql-connector-java>5.1.14</iresolve-core.mysql-connector-java> -->        		<iresolve-core.hibernate-entitymanager-version>3.6.0.final</iresolve-core.hibernate-entitymanager-version>        		<iresolve-core.hibernate-validator.version>5.1.3.final</iresolve-core.hibernate-validator.version>          		<iresolve-core.aspectj.version>1.5.4</iresolve-core.aspectj.version>        		<iresolve-core.junit.version>4.9</iresolve-core.junit.version>        		<iresolve-core.org.springframework.version>4.1.5.release</iresolve-core.org.springframework.version>          		<iresolve-core.org.springframework-security-version>3.2.3.release</iresolve-core.org.springframework-security-version>          		<iresolve-core.javassist.version>3.3</iresolve-core.javassist.version>        		<org.tiles-version>3.0.3</org.tiles-version>            	</properties>          	<dependencies>          		<!-- logging dependencies slf4j -->        		<dependency>      			<groupid>org.slf4j</groupid>      			<artifactid>slf4j-log4j12</artifactid>      			<version>${org.slf4j-version}</version>      		</dependency>      		<dependency>      			<groupid>org.slf4j</groupid>      			<artifactid>jcl-over-slf4j</artifactid>      			<version>${org.slf4j-version}</version>      			<scope>runtime</scope>      		</dependency>        		<dependency>      			<groupid>org.slf4j</groupid>      			<artifactid>slf4j-api</artifactid>      			<version>${org.slf4j-version}</version>      		</dependency>        		<dependency>      			<groupid>log4j</groupid>      			<artifactid>log4j</artifactid>      			<version>1.2.16</version>      			<scope>runtime</scope>      		</dependency>            		<!-- javassist proxy solution -->        		<dependency>      			<groupid>javassist</groupid>      			<artifactid>javassist</artifactid>      			<version>${iresolve-core.javassist.version}</version>      		</dependency>        		<!-- image decode -->      		<dependency>      			<groupid>commons-codec</groupid>      			<artifactid>commons-codec</artifactid>      			<version>1.9</version>      		</dependency>        		<!-- hibernate -->      		        		<dependency>      			<groupid>org.hibernate</groupid>      			<artifactid>hibernate-core</artifactid>      			<version>${iresolve-core.hibernate-entitymanager-version}</version>      			<exclusions>      				<exclusion>      					<artifactid>javassist</artifactid>      					<groupid>org.javassist</groupid>      				</exclusion>      			</exclusions>      		</dependency>      		<dependency>      			<groupid>org.hibernate</groupid>      			<artifactid>hibernate-entitymanager</artifactid>      			<version>${iresolve-core.hibernate-entitymanager-version}</version>      			<exclusions>      				<exclusion>      					<groupid>asm</groupid>      					<artifactid>asm</artifactid>      				</exclusion>      				<exclusion>      					<groupid>asm</groupid>      					<artifactid>asm-attrs</artifactid>      				</exclusion>      				<exclusion>      					<groupid>cglib</groupid>      					<artifactid>cglib</artifactid>      				</exclusion>      				<exclusion>      					<artifactid>javassist</artifactid>      					<groupid>javassist</groupid>      				</exclusion>      				<exclusion>      					<groupid>org.hibernate</groupid>      					<artifactid>hibernate-core</artifactid>      				</exclusion>        			</exclusions>      		</dependency>      		      		<!-- dependencies hibernate , orm  -->		      		<dependency>      			<groupid>com.h2database</groupid>      			<artifactid>h2</artifactid>      		    <version>1.3.156</version>      		</dependency>      	        		<!-- dependencies sqlite -->      		<dependency>      			<groupid>org.xerial</groupid>      			<artifactid>sqlite-jdbc</artifactid>      			<version>3.8.11.2</version>      		</dependency>      		<!-- <dependency>      			<groupid>net.kemitix</groupid>      			<artifactid>sqlite-dialect</artifactid>      			<version>0.1.0</version>      		</dependency> -->	                             <!-- sqlite jdbc library               <dependency>                  <groupid>org.xerial</groupid>                  <artifactid>sqlite-jdbc</artifactid>                  <version>3.8.11.2</version>              </dependency>-->        		<!-- jsr 303 hibernate validator -->        		<dependency>      			<groupid>org.hibernate</groupid>      			<artifactid>hibernate-validator</artifactid>      			<version>${iresolve-core.hibernate-validator.version}</version>        		</dependency>      		<!-- jsoooooon -->      		<dependency>      			<groupid>com.googlecode.json-simple</groupid>      			<artifactid>json-simple</artifactid>      			<version>1.1</version>      		</dependency>      		<dependency>      			<groupid>org.json</groupid>      			<artifactid>json</artifactid>      			<version>20150729</version>      		</dependency>          		<!-- **************************** spring ***************************************** -->        		<dependency>      			<groupid>org.springframework</groupid>      			<artifactid>spring-beans</artifactid>      			<version>${iresolve-core.org.springframework.version}</version>      		</dependency>      		<dependency>      			<groupid>org.springframework</groupid>      			<artifactid>spring-context</artifactid>      			<version>${iresolve-core.org.springframework.version}</version>      		</dependency>      		<dependency>      			<groupid>org.springframework</groupid>      			<artifactid>spring-core</artifactid>      			<version>${iresolve-core.org.springframework.version}</version>          			<exclusions>      				<exclusion>      					<groupid>commons-logging</groupid>      					<artifactid>commons-logging</artifactid>      				</exclusion>      			</exclusions>          		</dependency>      		<dependency>      			<groupid>org.springframework</groupid>      			<artifactid>spring-expression</artifactid>      			<version>${iresolve-core.org.springframework.version}</version>      		</dependency>      		<dependency>      			<groupid>org.springframework</groupid>      			<artifactid>spring-orm</artifactid>      			<version>${iresolve-core.org.springframework.version}</version>      		</dependency>      		<dependency>      			<groupid>org.springframework</groupid>      			<artifactid>spring-web</artifactid>      			<version>${iresolve-core.org.springframework.version}</version>      		</dependency>          		<dependency>      			<groupid>org.springframework</groupid>      			<artifactid>spring-webmvc</artifactid>      			<version>${iresolve-core.org.springframework.version}</version>      		</dependency>      		<!-- postgres connector       		<dependency>      			<groupid>org.postgresql</groupid>      			<artifactid>postgresql</artifactid>      			<version>9.4-1200-jdbc41</version>      		</dependency>-->        		<!-- spring security -->          		<dependency>      			<groupid>org.springframework.security</groupid>      			<artifactid>spring-security-core</artifactid>      			<version>${iresolve-core.org.springframework-security-version}</version>      			<exclusions>      				<exclusion>      					<artifactid>spring-tx</artifactid>      					<groupid>org.springframework</groupid>      				</exclusion>      			</exclusions>      		</dependency>        		<dependency>      			<groupid>org.springframework.security</groupid>      			<artifactid>spring-security-web</artifactid>      			<version>${iresolve-core.org.springframework-security-version}</version>      			<exclusions>      				<exclusion>      					<artifactid>spring-tx</artifactid>      					<groupid>org.springframework</groupid>      				</exclusion>      			</exclusions>      		</dependency>        		<dependency>      			<groupid>org.springframework.security</groupid>      			<artifactid>spring-security-config</artifactid>      			<version>${iresolve-core.org.springframework-security-version}</version>      		</dependency>        		<dependency>      			<groupid>org.springframework.security</groupid>      			<artifactid>spring-security-taglibs</artifactid>      			<version>${iresolve-core.org.springframework-security-version}</version>      			<exclusions>      				<exclusion>      					<artifactid>spring-tx</artifactid>      					<groupid>org.springframework</groupid>      				</exclusion>      			</exclusions>      		</dependency>              		<!-- aspectj -->      		<dependency>      			<groupid>aspectj</groupid>      			<artifactid>aspectjrt</artifactid>      			<version>${iresolve-core.aspectj.version}</version>      		</dependency>      		<dependency>      			<groupid>aspectj</groupid>      			<artifactid>aspectjweaver</artifactid>      			<version>${iresolve-core.aspectj.version}</version>      		</dependency>          		<!-- commons utilities dependencies -->            		<dependency>      			<groupid>commons-fileupload</groupid>      			<artifactid>commons-fileupload</artifactid>      			<version>1.2.2</version>      		</dependency>        		<dependency>      			<groupid>commons-io</groupid>      			<artifactid>commons-io</artifactid>      			<version>2.0.1</version>      		</dependency>        		<dependency>      			<groupid>commons-collections</groupid>      			<artifactid>commons-collections</artifactid>      			<version>3.2.1</version>      		</dependency>        		<dependency>      			<groupid>commons-validator</groupid>      			<artifactid>commons-validator</artifactid>      			<version>1.4.0</version>      		</dependency>          		<dependency>      			<groupid>org.apache.commons</groupid>      			<artifactid>commons-lang3</artifactid>      			<version>3.0</version>      		</dependency>            		<dependency>      			<groupid>javax.annotation</groupid>      			<artifactid>jsr250-api</artifactid>      			<version>1.0</version>      		</dependency>          		<dependency>      			<groupid>javax.transaction</groupid>      			<artifactid>jta</artifactid>      			<version>1.1</version>      			<scope>provided</scope>      		</dependency>          		<!-- @inject -->      		<dependency>      			<groupid>javax.inject</groupid>      			<artifactid>javax.inject</artifactid>      			<version>1</version>      		</dependency>          		<!-- servlet -->      		<dependency>      			<groupid>javax.servlet</groupid>      			<artifactid>servlet-api</artifactid>      			<version>2.5</version>      			<scope>provided</scope>      		</dependency>      		<dependency>      			<groupid>javax.servlet.jsp</groupid>      			<artifactid>jsp-api</artifactid>      			<version>2.1</version>      			<scope>provided</scope>      		</dependency>      		<dependency>      			<groupid>javax.servlet.jsp.jstl</groupid>      			<artifactid>jstl-api</artifactid>      			<version>1.2</version>      		</dependency>        		<dependency>      			<groupid>jstl</groupid>      			<artifactid>jstl</artifactid>      			<version>1.2</version>      		</dependency>        		<!-- apache tiles -->        		<dependency>      			<groupid>org.apache.tiles</groupid>      			<artifactid>tiles-jsp</artifactid>      			<version>${org.tiles-version}</version>      		</dependency>        		<!-- jackson json processor -->          		<dependency>      			<groupid>org.codehaus.jackson</groupid>      			<artifactid>jackson-core-asl</artifactid>      			<version>1.9.13</version>      		</dependency>      		<dependency>      			<groupid>org.codehaus.jackson</groupid>      			<artifactid>jackson-mapper-asl</artifactid>      			<version>1.9.13</version>      		</dependency>        		<dependency>      			<groupid>com.fasterxml.jackson.core</groupid>      			<artifactid>jackson-databind</artifactid>      			<version>2.4.3</version>      		</dependency>          		<dependency>      			<groupid>org.springframework</groupid>      			<artifactid>spring-context-support</artifactid>      			<version>${iresolve-core.org.springframework.version}</version>      		</dependency>            		<dependency>      			<groupid>junit</groupid>      			<artifactid>junit</artifactid>      			<version>4.4</version>      		</dependency>          		<dependency>      			<groupid>org.springframework</groupid>      			<artifactid>spring-test</artifactid>      			<version>2.5</version>      		</dependency>        		<dependency>      			<groupid>javax.mail</groupid>      			<artifactid>mail</artifactid>      			<version>1.4.7</version>      		</dependency>        		<!-- jsonencoder pom -->        		<dependency>      			<groupid>net.sf.flexjson</groupid>      			<artifactid>flexjson</artifactid>      			<version>2.0</version>      		</dependency>      	</dependencies>          	<build>      		<plugins>      			<plugin>      				<artifactid>maven-eclipse-plugin</artifactid>      				<version>2.9</version>      				<configuration>      					<additionalprojectnatures>      						<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>      					</additionalprojectnatures>      					<additionalbuildcommands>      						<buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>      					</additionalbuildcommands>      					<downloadsources>true</downloadsources>      					<downloadjavadocs>true</downloadjavadocs>      				</configuration>      			</plugin>      			<plugin>      				<groupid>org.apache.maven.plugins</groupid>      				<artifactid>maven-compiler-plugin</artifactid>      				<version>2.5.1</version>      				<configuration>      					<source>1.6</source>      					<target>1.6</target>      					<compilerargument>-xlint:all</compilerargument>      					<showwarnings>true</showwarnings>      					<showdeprecation>true</showdeprecation>      				</configuration>      			</plugin>      			<plugin>      				<groupid>org.codehaus.mojo</groupid>      				<artifactid>exec-maven-plugin</artifactid>      				<version>1.2.1</version>      				<configuration>      					<mainclass>org.test.int1.main</mainclass>      				</configuration>      			</plugin>      		</plugins>      		<finalname>${project.artifactid}</finalname>      	</build>      </project>

sqlitedialect.java        package org.hibernate.dialect;            import java.sql.types;        import org.hibernate.dialect.function.abstractansitrimemulationfunction;      import org.hibernate.dialect.function.noargsqlfunction;      import org.hibernate.dialect.function.sqlfunction;      import org.hibernate.dialect.function.sqlfunctiontemplate;      import org.hibernate.dialect.function.standardsqlfunction;      import org.hibernate.dialect.function.varargssqlfunction;      import org.hibernate.type.standardbasictypes;        public class sqlitedialect extends dialect {        public sqlitedialect() {          registercolumntype(types.bit, "integer");          registercolumntype(types.tinyint, "tinyint");          registercolumntype(types.smallint, "smallint");          registercolumntype(types.integer, "integer");          registercolumntype(types.bigint, "bigint");          registercolumntype(types.float, "float");          registercolumntype(types.real, "real");          registercolumntype(types.double, "double");          registercolumntype(types.numeric, "numeric");          registercolumntype(types.decimal, "decimal");          registercolumntype(types.char, "char");          registercolumntype(types.varchar, "varchar");          registercolumntype(types.longvarchar, "longvarchar");          registercolumntype(types.date, "date");          registercolumntype(types.time, "time");          registercolumntype(types.timestamp, "timestamp");          registercolumntype(types.binary, "blob");          registercolumntype(types.varbinary, "blob");          registercolumntype(types.longvarbinary, "blob");          // registercolumntype(types.null, "null");          registercolumntype(types.blob, "blob");          registercolumntype(types.clob, "clob");          registercolumntype(types.boolean, "boolean");            registerfunction( "concat", new varargssqlfunction(standardbasictypes.string, "", "||", "") );          registerfunction( "mod", new sqlfunctiontemplate(standardbasictypes.integer, "?1 % ?2" ) );          registerfunction( "quote", new standardsqlfunction("quote", standardbasictypes.string) );          registerfunction( "random", new noargsqlfunction("random", standardbasictypes.integer) );          registerfunction( "round", new standardsqlfunction("round") );          registerfunction( "substr", new standardsqlfunction("substr", standardbasictypes.string) );          registerfunction( "trim", new abstractansitrimemulationfunction() {              protected sqlfunction resolvebothspacetrimfunction() {                return new sqlfunctiontemplate(standardbasictypes.string, "trim(?1)");              }                protected sqlfunction resolvebothspacetrimfromfunction() {                return new sqlfunctiontemplate(standardbasictypes.string, "trim(?2)");              }                protected sqlfunction resolveleadingspacetrimfunction() {                return new sqlfunctiontemplate(standardbasictypes.string, "ltrim(?1)");              }                protected sqlfunction resolvetrailingspacetrimfunction() {                return new sqlfunctiontemplate(standardbasictypes.string, "rtrim(?1)");              }                protected sqlfunction resolvebothtrimfunction() {                return new sqlfunctiontemplate(standardbasictypes.string, "trim(?1, ?2)");              }                protected sqlfunction resolveleadingtrimfunction() {                return new sqlfunctiontemplate(standardbasictypes.string, "ltrim(?1, ?2)");              }                protected sqlfunction resolvetrailingtrimfunction() {                return new sqlfunctiontemplate(standardbasictypes.string, "rtrim(?1, ?2)");              }          } );        }          public boolean supportsidentitycolumns() {          return true;        }          /*        public boolean supportsinsertselectidentity() {          return true; // specify in nhibernate dialect        }        */          public boolean hasdatatypeinidentitycolumn() {          return false; // specify in nhibernate dialect        }          /*        public string appendidentityselecttoinsert(string insertstring) {          return new stringbuffer(insertstring.length()+30). // specify in nhibernate dialect            append(insertstring).            append("; ").append(getidentityselectstring()).            tostring();        }        */          public string getidentitycolumnstring() {          // return "integer primary key autoincrement";          return "integer";        }          public string getidentityselectstring() {          return "select last_insert_rowid()";        }          public boolean supportslimit() {          return true;        }          protected string getlimitstring(string query, boolean hasoffset) {          return new stringbuffer(query.length()+20).            append(query).            append(hasoffset ? " limit ? offset ?" : " limit ?").            tostring();        }          public boolean supportstemporarytables() {          return true;        }          public string getcreatetemporarytablestring() {          return "create temporary table if not exists";        }          public boolean droptemporarytableafteruse() {          return false;        }          public boolean supportscurrenttimestampselection() {          return true;        }          public boolean iscurrenttimestampselectstringcallable() {          return false;        }          public string getcurrenttimestampselectstring() {          return "select current_timestamp";        }          public boolean supportsunionall() {          return true;        }          public boolean hasaltertable() {          return false; // specify in nhibernate dialect        }          public boolean dropconstraints() {          return false;        }          public string getaddcolumnstring() {          return "add column";        }          public string getforupdatestring() {          return "";        }          public boolean supportsouterjoinforupdate() {          return false;        }          public string getdropforeignkeystring() {          throw new unsupportedoperationexception("no drop foreign key syntax supported sqlitedialect");        }          public string getaddforeignkeyconstraintstring(string constraintname,            string[] foreignkey, string referencedtable, string[] primarykey,            boolean referencesprimarykey) {          throw new unsupportedoperationexception("no add foreign key syntax supported sqlitedialect");        }          public string getaddprimarykeyconstraintstring(string constraintname) {          throw new unsupportedoperationexception("no add primary key syntax supported sqlitedialect");        }          public boolean supportsifexistsbeforetablename() {          return true;        }          public boolean supportscascadedelete() {          return false;        }      }

after changing sqlite dialect (like here hibernate + sqlite not creating database) , reference correctly:

<prop key="hibernate.dialect">com.mypackaged.dialect.sqlitedialect</prop> 

and changing hbm2ddl.auto propery "update":

<prop key="hibernate.hbm2ddl.auto">update</prop> 

... have tried put absolute url (with w / r permissions) in jdbc url property?

for example:

<property name="url" value="jdbc:sqlite:c:\\franchise.db" /> (in windows) 

check if database created on right path (c:/franchise.db).


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -