[Hibernate-JIRA] Created: (HHH-6648) @GeneratedValue not setting up auto increment in mysql and h2 dialects
by Brad Maxwell (JIRA)
@GeneratedValue not setting up auto increment in mysql and h2 dialects
----------------------------------------------------------------------
Key: HHH-6648
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6648
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 4.0.0.Beta5
Environment: AS 7.0.1
Reporter: Brad Maxwell
Attachments: h2.txt, mysql.txt
I took this application that uses hibernate and moved it to AS 7.0.1. I found that when using the H2 database, it fails complaining that the id is null. I tried changing it to use the HSQL dialect and had the same issue. Then I changed the datasource and dialect to MySQL and I got the same error. I'm attaching the full stack traces for mysql and h2.
I then switched to Oracle ds / dialect and it worked fine.
I examined the database tables and found that it was not set to auto increment. So I manually modified the database tables and that allowed the hibernate calls to succeed.
@Entity()
@Table()
public class EAPVersion implements Serializable
{
@Id @GeneratedValue(strategy=GenerationType.AUTO) @Column(name="id")
private int id;
@Column(name="name")
private String name;
@OneToMany(cascade=CascadeType.ALL) //, mappedBy="id")
@JoinColumn(name="EAPVersion_ID")
private List<Component> components = new ArrayList<Component>();
...
}
...
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Field 'id' doesn't have a default value
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1344)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1277)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1283)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:851)
at com.jboss.support.Cache.getEAPVersions(Cache.java:131)
at com.jboss.support.SourceCodeBean.getEapVersionsItems(SourceCodeBean.java:122)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:302)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175)
at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
at org.apache.el.parser.AstValue.getValue(AstValue.java:134)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:187)
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
... 36 more
Caused by: org.hibernate.exception.GenericJDBCException: Field 'id' doesn't have a default value
at org.hibernate.exception.internal.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:148)
at org.hibernate.exception.internal.SQLStateConverter.convert(SQLStateConverter.java:136)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:124)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109)
at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:131)
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:80)
at $Proxy22.executeUpdate(Unknown Source)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:95)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:54)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2753)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3259)
at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:78)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:273)
at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:301)
at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:192)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:127)
at org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:78)
at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:178)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:134)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:64)
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:718)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:694)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:698)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:845)
... 48 more
Caused by: java.sql.SQLException: Field 'id' doesn't have a default value
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2625)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2333)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2318)
at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:493)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:124)
... 67 more
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 10 months
[Hibernate-JIRA] Created: (BVAL-197) validation of a persisted map
by tho gau (JIRA)
validation of a persisted map
-----------------------------
Key: BVAL-197
URL: http://opensource.atlassian.com/projects/hibernate/browse/BVAL-197
Project: Bean Validation
Issue Type: Bug
Environment: hibernate-core 3.5.0-Beta-3
Validator 4.0.1.GA
MySQL 5.1
Reporter: tho gau
Attachments: mapValidation.zip
Hi,
I am trying to validate an entity that holds a Map<K, V> of other persisted entities (just checking wether the map holds some predefined values).
I can validate it "by hand" using validator.validate() and my map is correctly filled at validation time
However when validation framework is called by persistence callbacks, my map is always empty...
I am using Validator 4.0.1.GA and hibernate-core 3.5.0-Beta-2
I tryed to pinpoint the problem and it seems that the map is not touched in the following method of AbstractType during the merge :
{code}
public Object replace(
Object original, Object target, SessionImplementor session,
Object owner, Map copyCache, ForeignKeyDirection foreignKeyDirection) throws HibernateException {
boolean include;
if ( isAssociationType() ) {
AssociationType atype = (AssociationType) this;
include = atype.getForeignKeyDirection()==foreignKeyDirection;
}
else {
include = ForeignKeyDirection.FOREIGN_KEY_FROM_PARENT==foreignKeyDirection;
}
return include ? replace(original, target, session, owner, copyCache) : target;
}
{code}
--
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
12 years, 10 months
[Hibernate-JIRA] Created: (BVAL-243) Provide a means for specifying method parameter names
by Gunnar Morling (JIRA)
Provide a means for specifying method parameter names
-----------------------------------------------------
Key: BVAL-243
URL: http://opensource.atlassian.com/projects/hibernate/browse/BVAL-243
Project: Bean Validation
Issue Type: Sub-task
Reporter: Gunnar Morling
Emmanuel wrote:
{quote}
On named parameters we have three strategies I think:
- not address the problem at all and use positional parameters to see what comes up JDK 8's hat (named parameters might not be represented as strings but rather as a typed object)
- not address the problem in the specification but leave the API open enough for a provider to offer a named parameter friendly API
- address the problem within the spec (the interface approach seems elegant) hoping for the named parameter to be represented as a String in JDK 8
I tend to like param0, param1 etc rather than arg0, arg1 but that's aesthetic.
{quote}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 10 months
[Hibernate-JIRA] Created: (BVAL-245) Define how method constraints are declared at parameters and return values
by Gunnar Morling (JIRA)
Define how method constraints are declared at parameters and return values
--------------------------------------------------------------------------
Key: BVAL-245
URL: http://opensource.atlassian.com/projects/hibernate/browse/BVAL-245
Project: Bean Validation
Issue Type: Sub-task
Components: spec-general
Reporter: Gunnar Morling
Fix For: 1.1
Emmanuel:
{quote}
Constraints on parameters whose type is a subtype of the accepted types by the constraint are declared directly on the parameter
void doHarm(@NotEmpty String kittenName);
Constrains on parameters whose type is a constrained bean needs an annotation accepting the targeted groups. It was proposed to use @Valid for such case but [recent discussions|https://hibernate.onjira.com/browse/BVAL-208?focusedCommentId...] brought that back on the drawing board.
There are a few notions floating around @Valid
1. cascade validation to nested beans
2. translate the validation of group A from the owning bean to validation of the group B on the nested bean (see BVAL-208)
3. define the group to validate in a method level validation
About 3., I wonder if this should be part of Bean Validation or be part of the interception framework. In other words:
* should it be an annotation provided / proposed by Bean Validation and recognized by interception techs like CDI, @Inject, Spring, AspectJ etc
* should each interception tech provide its own annotation to specify the targeted group(s)
{quote}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 10 months