[Hibernate-JIRA] Created: (HHH-2852) usefull error messages, for instance when schema validation fails
by Eirik Maus (JIRA)
usefull error messages, for instance when schema validation fails
-----------------------------------------------------------------
Key: HHH-2852
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2852
Project: Hibernate3
Issue Type: New Feature
Components: core
Affects Versions: 3.2.0.ga
Reporter: Eirik Maus
Error messages from Hibernate should contain sufficient amount of details to make it possible to locate the problem.
Using hibernate in a large project is a mixed blessing. It does indeed save you from a lot of difficult and tedious work when everything is okay, but errors during startup are almost impossible to locate due to lack of detail. See for instance the following startup error:
[blah, blah, blah .... could not start .... exception ...blah, blah, blah,...]
Caused by:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateSessionFactory' defined in class path resource [applicationContext-blankett.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Wrong column type: utstedt_dato, expected: date
Caused by:
org.hibernate.HibernateException: Wrong column type: utstedt_dato, expected: date
at org.hibernate.mapping.Table.validateColumns(Table.java:251)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1007)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:317)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1218)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:807)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:740)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:131)
at no.bbs.common.hibernate.HibernateSessionFactoryBean.afterPropertiesSet(HibernateSessionFactoryBean.java:121)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1062)
.....
I have 3 different hibernate datasources, 8 different *.hbm.xml files from 5 different domain-logic modules, containing in all 9 different columns with that name. Some 15-20 people make modifications to the code base and mappings regularly. It is not so easy to find out who to ask about this problem from the error message provided. Thanks to spring I get an idea of which datasource that failed to start: it prints out which bean that failed creation and where it was defined. Still, it doesn't help me to pinpoint the problem. Why doesn't Configuration even print out which table it is trying to validate? Spending lots of time trying to track down such errors is truly a waste. All the required information was available inside hibernate at the time of the problem, only it wasn't printed out to the user.
Other error messages in hibernate are sometimes poor, too, but this is probably the worst.
At least Configuration must print out the following info:
* table name and mapped class (fully qualified name)
* column name and expected data type (as it does today)
* The URL (or, at least, file name) of the mapping file defining the "problem"
* ... or something else for other sources of mapping info (like annotations), I have no idea what,
Also, the following should really be printed as well
* actual data type found in the schema
* datasource URL
* datasource user name
(The hibernate developers should look to tapestry for how to make deverloper-friendly error diagnostics. A lot of bad things can be (is) said about that project and its leaders, but at least they provide really really nice error messages that directly points out your error so you don't have to spend hours and hours trying to analyze/guess what and where things went wrong)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
18 years, 3 months
[Hibernate-JIRA] Created: (HHH-3026) Impossible cyclic requirement causes misleading error
by Dobes Vandermeer (JIRA)
Impossible cyclic requirement causes misleading error
-----------------------------------------------------
Key: HHH-3026
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3026
Project: Hibernate3
Issue Type: Improvement
Affects Versions: 3.2.5
Reporter: Dobes Vandermeer
When you create an impossible cycle, for example:
class A {
@OneToMany(inverse="a")
List<A> listOfA = new ArrayList<A>();
@OneToOne(optional=false)
B specialB;
}
class B {
@ManyToOne(optional=false)
A a;
}
It's actually impossible for hibernate to insert the B referenced by 'specialB', because in order to insert it, A must have a valid primary key. In order to insert A, b must have a primary key.
This is fine, and I accept that hibernate does not work around this problem. However, the error message hibernate provides isn't just useless, it's actually misleading:
"not-null property references a null or transient value"
This message sent me on a useless multi-hour quest looking for a null or transient value, of which there were none.
If possible, hibernate should detect and report this as cyclic dependency when it flushes, and print a nicer error like:
"Instance of A requires B to have been inserted, but B also requires A to have been inserted; please make one of these properties nullable"
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
18 years, 3 months
[Hibernate-JIRA] Commented: (HHH-1483) MySQL5: No Dialect mapping for JDBC type: -1
by yaolin (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1483?page=c... ]
yaolin commented on HHH-1483:
-----------------------------
Hibernate core 3.2.0 ga is affected too.
> MySQL5: No Dialect mapping for JDBC type: -1
> --------------------------------------------
>
> Key: HHH-1483
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1483
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1.2
> Environment: MySQL 5.0.18-nt
> Reporter: Sergey Vladimirov
> Priority: Minor
>
> MySQL5: No Dialect mapping for JDBC type: -1
> SELECT answpos,answer FROM votes_answers WHERE question=? ORDER BY answpos
> mysql> describe votes_answers;
> +----------+---------+------+-----+---------+-------+
> | Field | Type | Null | Key | Default | Extra |
> +----------+---------+------+-----+---------+-------+
> | question | int(11) | NO | MUL | | |
> | answpos | int(11) | NO | | | |
> | answer | text | YES | | NULL | |
> +----------+---------+------+-----+---------+-------+
> mysql> describe temp;
> +---------+---------+------+-----+---------+-------+
> | Field | Type | Null | Key | Default | Extra |
> +---------+---------+------+-----+---------+-------+
> | answpos | int(11) | NO | | 0 | |
> | answer | text | YES | | NULL | |
> +---------+---------+------+-----+---------+-------+
> Please, let me know what to add to MySQL5Dialect :)
> Will it be ok to add? :
> registerColumnType( Types.LONGVARCHAR, "text" );
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
18 years, 3 months
[Hibernate-JIRA] Created: (HBX-1027) Reveng of Oracle db finds wrong lengths for unicode CHAR columns
by Matthew Lieder (JIRA)
Reveng of Oracle db finds wrong lengths for unicode CHAR columns
----------------------------------------------------------------
Key: HBX-1027
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-1027
Project: Hibernate Tools
Issue Type: Bug
Components: reverse-engineer
Affects Versions: 3.2.cr1
Environment: Oracle 9i
Reporter: Matthew Lieder
This is a shortened version of the query currently used by OracleMetaDataDialect:
select decode(a.data_type, 'FLOAT',decode(a.data_precision,null, a.data_length, a.data_precision), 'NUMBER', decode(a.data_precision,null, a.data_length, a.data_precision), a.data_length) as COLUMN_SIZE
from all_tab_columns a
That works fine for CHAR(? Byte) columns, but returns ?*4 for CHAR(? Char) columns (where ? is any integer). I'm guessing that occurs because one ANSI character takes up 1 byte while one UNICODE character takes up 4 bytes, and COLUMN_SIZE is meant to represent the number of characters in a string column and not the number of bytes used to store the string in the database.
The solution is to use "a.char_length" for any string-based data types (CHAR, VARCHAR2, etc.):
decode(a.data_type, 'FLOAT',decode(a.data_precision,null, a.data_length, a.data_precision), 'NUMBER', decode(a.data_precision,null, a.data_length, a.data_precision), 'CHAR', a.char_length, 'VARCHAR2', a.char_length, a.data_length) as COLUMN_SIZE
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
18 years, 3 months
[Hibernate-JIRA] Created: (HHH-3022) Incorrect SQL with not-equal operator '<>' on entities with composite key
by Matthias Lanz (JIRA)
Incorrect SQL with not-equal operator '<>' on entities with composite key
-------------------------------------------------------------------------
Key: HHH-3022
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3022
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.4.sp1, 3.2.3
Environment: MySQL with Connector/J 5.0.6
Tested on JBoss jboss-eap-4.2cp01
Reporter: Matthias Lanz
Wrong SQL is generated when using "<>" in EJBQL on entities with composite keys.
EJB QL:
Customer c= em.find(Customer.class, [...])
query= em.createQuery("UPDATE Customer c SET [...] WHERE [...] AND c <> :customer");
query.setParameter("customer", customer);
Customer.class has a composite key with @EmbeddedId (String mand, long id)
The SQL is missing a NOT and the brackets around the composite-key condition and therefore the boolean expression is true even if one part of the composite key matches:
NOT condition1 AND NOT condition2
update CustCustomer set [...] where [...] and mand<>? and id<>?
but is has to be
NOT (condition1 AND condition2)
update CustCustomer set [...] where [...] and NOT (mand=? and id=?)
Workaround:
"UPDATE Customer c SET [...] WHERE [...] AND c NOT IN (:customer)"
which results in
(id,mand) NOT IN ((?,?))
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
18 years, 3 months
[Hibernate-JIRA] Commented: (HHH-1582) PostInsertListener + "post-commit-insert"
by Darren Bell (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1582?page=c... ]
Darren Bell commented on HHH-1582:
----------------------------------
Thanks for that. I try it out. Me needs to learn more. :)
> PostInsertListener + "post-commit-insert"
> -----------------------------------------
>
> Key: HHH-1582
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1582
> Project: Hibernate3
> Issue Type: Bug
> Affects Versions: 3.1.2
> Reporter: Daniel Gredler
> Assignee: Emmanuel Bernard
> Fix For: 3.3
>
> Original Estimate: 3 hours
> Remaining Estimate: 3 hours
>
> I'm using a custom PostInsertEventListener mapped to the "post-commit-insert" event to process domain objects. However, PostInsertEventListener's onPostInsert(PostInsertEvent) is getting called even when the insert was not successful (ie, due to a unique constraint in the database or some such). It looks to me like Hibernate should either a) not invoke the event listener if the insert failed or b) provide state (perhaps in the form of a boolean indicating success/failure). Personally I'd rather the method not be called on failure, but there may be use cases out there for the second option.
> As an example, it looks like Hibernate's own LuceneEventListener will add a domain object to the index in onPostInsert(PostInsertEvent) even if the insert failed.
> Note that this problem also seems to exist in EntityDeleteAction and EntityUpdateAction (which would mean that Hibernate's LuceneEventListener removes domain objects from the Lucene index even if the delete fails!).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
18 years, 3 months