Sto utilizzando l'ibernazione con derby incorporato, e voglio che hibernate crei il database e le tabelle, quindi ho provato la seguente configurazione, ma sto ricevendo l'errore:java.sql.SQLException: Schema "ROOT" inesistente
java.sql.SQLException: Schema 'ROOT' does not exist
qui/s la mia configurazione:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.myapp.domain" />
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.DerbyDialect
hibernate.hbm2ddl.auto=create
hibernate.show_sql=false
hibernate.format_sql=false
</value>
</property>
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" />
<property name="url" value="jdbc:derby:test;create=true" />
<property name="username" value="root" />
<property name="password" value="root" />
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
UPDATE: è il mio primo utilizzo di derby così ho forse avere qualche informazioni mancanti, quindi ho una domanda:
Devo configurare Derby Embedded come qui:
http://db.apache.org/derby/papers/DerbyTut/install_software.html
UPDATE 2: Ho rimosso il file di script import.sql sul classpath, che è responsabile per l'inserimento dei dati nel database demo, e ho scoperto che ci sia un errore nella creazione della tabella del database:
1202 [main] INFO org.hibernate.tool.hbm2ddl.SchemaExport - Running hbm2ddl schema export
1202 [main] INFO org.hibernate.tool.hbm2ddl.SchemaExport - exporting generated schema to database
1359 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaExport - Unsuccessful: create table users (user_id bigint generated by default as identity unique, address varchar(255), email varchar(155) not null, mobile varchar(25), name varchar(25) not null, password varchar(255) not null, primary key (user_id))
1359 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaExport - Constraints 'SQL111223214919671' and 'SQL111223214919670' have the same set of columns, which is not allowed.
1359 [main] INFO org.hibernate.tool.hbm2ddl.SchemaExport - schema export complete
1360 [main] WARN org.hibernate.util.JDBCExceptionReporter - SQL Warning: 10000, SQLState: 01J01
1360 [main] WARN org.hibernate.util.JDBCExceptionReporter - Database 'test' not created, connection made to existing database instead.
derby mai usato. ma hai definito l'utente "root" per il database (con accesso alla base di test) – Vinze
beh, ho appena provato la configurazione come qui, e ho pensato che dovrebbe creare il database con sopra utente/passaggio http: // stackoverflow.com/questions/8459284/using-hibernate-with-embedded-derby/8463463#comment10693363_8463463 –
heres un tut driver incorporato: https://db.apache.org/derby/papers/DerbyTut/embedded_intro.html. Ma il tuo codice sembra buono – oers