Closed GoogleCodeExporter closed 9 years ago
Please attach the project zip file.
Did you specify the Hibernate property hibernate.hbm2ddl.auto to create ?
I just run the test cases for the hibernate-audit project using a clean DB and
using the property hibernate.hbm2ddl.auto=create it did create the tables.
Original comment by kchobant...@gmail.com
on 7 Aug 2011 at 11:31
Yes I set it to create. That is why seq tables are created. Maybe it is mysql
problem? Anyway project is attached (I am just simply create session and try to
list audit entity, it should be created at that time). When you run that, you
will get:
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table
'audit.audit_event' doesn't exist
at sun.reflect.GeneratedConstructorAccessor3.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
Original comment by kol...@gmail.com
on 8 Aug 2011 at 5:39
Attachments:
I just tested that using the provided project but against Oracle XE - I changed
hibernate.cfg.xml with the following setting
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.password">hba</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:XE</property>
<property name="hibernate.connection.username">hba</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
and I have added the oracle driver jar file to the class path - all tables were
created.
Could you please install oracle XE - it is free for development and test it
against that if you do have the time ? It seems that this issue might be
related to the MySQL database dialect or something.
Let me know if you can confirm that it is working with Oracle on your machine -
I could install MySQL on my machine and give it a try if that is working on
your machine with Oracle XE.
Original comment by kchobant...@gmail.com
on 8 Aug 2011 at 3:51
I had some time to find problem. It is because you are explicitly using
NUMBER(30) as type. I modified it to BIGINT and it works. Maybe using
Annotations in opposite to hbm is better, because it automatically choose
correct DB type.
Original comment by kol...@gmail.com
on 10 Aug 2011 at 9:31
Attachments:
Hi,
Thanks for taking the time to find the root cause when using MySQL.
Yes, currently the mapping is done for Oracle only (or compatible DB) - if you
are using some other DB that does not support the specified types then you need
to create a new mapping file (you can use the provided one as a reference) -
There is also a configuration parameter where you can specify the location of
this new file mapping (it will use the class loader to find your class) or you
can just place a this new file in the same location (e.g com/googlecode/... )
but this to be in the classpath before the hibernate-audit jar file.
We are not using hibernate annotation on purpose - first it will make a
dependency to this library and second it will not work with EMF (Eclipse
Modeling Framework) persistence models using Teneo.
Krasimir
Original comment by kchobant...@gmail.com
on 10 Aug 2011 at 9:46
The configuration property is "hba.mappingfile" - you can read about that in
the wiki section of the project.
Original comment by kchobant...@gmail.com
on 10 Aug 2011 at 9:47
I have added a note in the wiki section regarding the HBM configuration using
database other than Oracle.
Original comment by kchobant...@gmail.com
on 10 Aug 2011 at 9:51
This is fixed in 1.0.30 version - now the default mapping does not have the
sql-type mappings - check the wiki section hba.mappingfile.
We now do support default mapping file per dialect - the framework provides
oracle specific mapping file if it detects that the hba.mappingfile is not uses
and the database is oracle it will use this mapping file unless you do have the
same resource location in the classpath and it is before the audit jar file.
Original comment by kchobant...@gmail.com
on 30 Aug 2011 at 8:46
Original comment by kchobant...@gmail.com
on 30 Aug 2011 at 8:49
Original issue reported on code.google.com by
kol...@gmail.com
on 7 Aug 2011 at 9:05