No, I don't skip them because further are things which makes duplicates.
For now I just clear index just before starting session factory:
so I make in Spring:
Code:
<bean name="removeIndex" class="com.test.RemoveIndex" init-method="init">
<property name="indexBase"><value>${indexBase}</value></property>
<property name="createDatabase"><value>${hibernate.hbm2ddl.auto}</value></property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" depends-on="removeIndex">
</bean>
And delete directory in RemoveIndex class:
Code:
public class RemoveIndex {
private static final String SVN = ".svn";
private String indexBase;
private static final String HIBERNATE_CREATE = "create";
private String createDatabase;
public void init() {
if(createDatabase.equals(HIBERNATE_CREATE)){
File[] files = new File(indexBase).listFiles();
for(File file : files) {
if(!file.getName().equals(SVN)) {
deleteDirectory(file);
}
}
}
}
public static boolean deleteDirectory(File path) {
if( path.exists() ) {
File[] files = path.listFiles();
for(int i=0; i<files.length; i++) {
if(files[i].isDirectory()) {
deleteDirectory(files[i]);
}
else {
files[i].delete();
}
}
}
return( path.delete() );
}
public String getIndexBase() {
return indexBase;
}
public void setIndexBase(String indexBase) {
this.indexBase = indexBase;
}
public String getCreateDatabase() {
return createDatabase;
}
public void setCreateDatabase(String createDatabase) {
this.createDatabase = createDatabase;
}
}
Maybe someone can provide better solution but this works for me perfectly now, and maybe helps someone in future.
Best regards,
Adr