-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate and Derby
PostPosted: Thu Mar 10, 2005 6:17 am 
Newbie

Joined: Tue Feb 22, 2005 8:43 pm
Posts: 3
Hibernate version:
Hibernate 2.1

Mapping documents:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">


<hibernate-mapping>

<class
name="xpetstore.domain.Order"
table="T_ORDER"
>

<id name="orderId" type="long" column="ORDERID">
<meta attribute="scope-set">protected</meta>
<generator class="identity"/>
</id>

<component
name="address"
class="xpetstore.domain.Address"
>
<property
name="city"
type="java.lang.String"
column="city"
length="25"
not-null="false"
unique="false"
/>

<property
name="country"
type="java.lang.String"
column="country"
length="3"
not-null="false"
unique="false"
/>

<property
name="state"
type="java.lang.String"
column="state"
length="3"
not-null="false"
unique="false"
/>

<property
name="street1"
type="java.lang.String"
column="street1"
length="50"
not-null="false"
unique="false"
/>

<property
name="street2"
type="java.lang.String"
column="street2"
length="50"
not-null="false"
unique="false"
/>

<property
name="zipcode"
type="java.lang.String"
column="zipcode"
length="10"
not-null="false"
unique="false"
/>

</component>

<component
name="creditCard"
class="xpetstore.domain.CreditCard"
>
<property
name="expiryDate"
type="java.lang.String"
column="creditCardExpiryDate"
length="10"
not-null="false"
unique="false"
/>

<property
name="number"
type="java.lang.String"
column="creditCardNumber"
length="25"
not-null="false"
unique="false"
/>

<property
name="type"
type="java.lang.String"
column="creditCardType"
length="25"
not-null="false"
unique="false"
/>

</component>

<many-to-one
name="customer"
class="xpetstore.domain.Customer"
column="customer_fk"
not-null="false"
unique="false"
cascade="none"
outer-join="auto"
/>

<property
name="orderDate"
type="java.util.Date"
column="orderDate"
not-null="false"
unique="false"
/>

<set
name="orderItems"
lazy="true"
inverse="false"
cascade="all"
sort="unsorted"
>

<key
column="order_fk"
>
</key>

<one-to-many
class="xpetstore.domain.OrderItem"
/>

</set>

<property
name="status"
type="java.lang.String"
column="status"
length="10"
not-null="false"
unique="false"
/>

<!--
To add non XDoclet properties, create a file named
hibernate-properties-Order.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>


Full stack trace of any exception that occurs:
could not insert: [xpetstore.domain.Order]<p><small><small><pre>net.sf.hibernate.exception.ConstraintViolationException: could not insert: [xpetstore.domain.Order]
at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:62)
at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at net.sf.hibernate.persister.AbstractEntityPersister.convert(AbstractEntityPersister.java:1331)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:540)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:426)
at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:28)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2449)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:943)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:868)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:786)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:749)
at xpetstore.web.webwork.action.order.CreateOrderAction.doExecute(CreateOrderAction.java:83)
at webwork.action.ActionSupport.execute(ActionSupport.java:151)
at xpetstore.web.webwork.action.BaseAction.execute(BaseAction.java:91)
at webwork.dispatcher.GenericDispatcher.executeAction(GenericDispatcher.java:131)
at webwork.dispatcher.ServletDispatcher.service(ServletDispatcher.java:174)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:427)
at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:816)
at xpetstore.web.filter.SignOnFilter.doFilter(SignOnFilter.java:127)
at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:807)
at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:807)
at org.mortbay.jetty.servlet.JSR154Filter.doFilter(JSR154Filter.java:169)
at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:807)
at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:488)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:569)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:624)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1434)
at org.mortbay.http.HttpServer.service(HttpServer.java:896)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:814)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:981)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:831)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:366)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Caused by: SQL Exception: Column 'ORDERID' cannot accept a NULL value.
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java)
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java)
at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(EmbedPreparedStatement.java)
at org.apache.derby.iapi.jdbc.BrokeredPreparedStatement.executeUpdate(BrokeredPreparedStatement.java)
at org.tranql.connector.jdbc.PreparedStatementHandle.executeUpdate(PreparedStatementHandle.java:103)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:518)
... 34 more
</pre></small></small></p>


Name and version of the database you are using:
Derby

The generated SQL (show_sql=true):
17:56:12,377 DEBUG [SQL] insert into T_ORDER (city, country, state, street1, street2, zipcode, creditCardExpiryDate, creditCardNumber, creditCardType, customer_fk, orderDate, status, ORDERID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, default)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.