1
Good afternoon I would like to know why this error is happening, the project is with all the jars in the lib and in the path but when I will insert is returning me an error.
Apr 19, 2014 4:49:27 PM org.hibernate.Annotations.common.Version INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final} Apr 19, 2014 4:49:27 PM org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {4.2.6.Final} Apr 19, 2014 4:49:27 PM org.hibernate.cfg.Environment INFO: HHH000205: Loaded properties from Resource Hibernate.properties: {Hibernate.connection.driver_class=org.H2.Driver, Hibernate.dialect=org.hibernate.dialect.H2dialect, Hibernate.max_fetch_depth=5, Hibernate.format_sql=true, Hibernate.generate_statistics=true, Hibernate.connection.username=sa, Hibernate.connection.url=jdbc:H2:Mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE, Hibernate.bytecode.use_reflection_optimizer=false, Hibernate.jdbc.batch_versioned_data=true, Hibernate.connection.pool_size=5} Apr 19, 2014 4:49:28 PM org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode Provider name : javassist Apr 19, 2014 4:49:29 PM org.hibernate.service.jdbc.Connections.internal.Drivermanagerconnectionproviderimpl configure INFO: HHH000402: Using Hibernate built-in Connection pool (not for Production use!) Apr 19, 2014 4:49:29 PM org.hibernate.service.jdbc.Connections.internal.Drivermanagerconnectionproviderimpl configure INFO: HHH000115: Hibernate Connection pool size: 5 Apr 19, 2014 4:49:29 pm org.hibernate.service.jdbc.Connections.internal.Drivermanagerconnectionproviderimpl configure INFO: HHH000006: Autocommit mode: true Apr 19, 2014 4:49:29 PM org.hibernate.service.jdbc.Connections.internal.Drivermanagerconnectionproviderimpl configure INFO: HHH000401: using driver [org.postgresql.Driver] at URL [jdbc:postgresql:/localhost/postgres] Apr 19, 2014 4:49:29 PM org.hibernate.service.jdbc.Connections.internal.Drivermanagerconnectionproviderimpl configure INFO: HHH000046: Connection properties: {user=postgres, password=***, autocommit=true, release_mode=auto} Apr 19, 2014 4:49:30 PM org.hibernate.dialect.Dialect INFO: HHH000400: Using dialect: org.hibernate.dialect.Postgresqldialect Apr 19, 2014 4:49:30 PM org.hibernate.engine.jdbc.Internal.Lobcreatorbuilder useContextualLobCreation INFO: HHH000423: Disabling contextual LOB Creation as JDBC driver reported JDBC version [3] Less than 4 Apr 19, 2014 4:49:30 pm org.hibernate.engine.transaction.Internal.Transactionfactoryinitiator initiateService INFO: HHH000268: Transaction Strategy: org.hibernate.engine.transaction.Internal.jdbc.Jdbctransactionfactory Apr 19, 2014 4:49:30 PM org.hibernate.hql.internal.Ast.Astquerytranslatorfactory INFO: HHH000397: Using Astquerytranslatorfactory SLF4J: Failed to load class "org.slf4j.impl.Staticloggerbinder". SLF4J: Defaulting to no-Operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further Details. Apr 19, 2014 4:49:31 pm org.hibernate.cache.spi.Updatetimestampscache INFO: HHH000250: Starting update timestamps cache at Region: org.hibernate.cache.spi.Updatetimestampscache Apr 19, 2014 4:49:31 PM org.hibernate.cache.ehcache.Abstractehcacheregionfactory getCache WARN: HHH020003: Could not find a specific ehcache Configuration for cache named [org.hibernate.cache.spi.Updatetimestampscache]; using defaults. Apr 19, 2014 4:49:31 pm org.hibernate.cache.internal.Standardquerycache INFO: HHH000248: Starting query cache at Region: org.hibernate.cache.internal.Standardquerycache Apr 19, 2014 4:49:31 PM org.hibernate.cache.ehcache.Abstractehcacheregionfactory getCache WARN: HHH020003: Could not find a specific ehcache Configuration for cache named [org.hibernate.cache.internal.Standardquerycache]; using defaults. Apr 19, 2014 4:49:32 PM org.hibernate.tool.hbm2ddl.Schemaupdate execute INFO: HHH000228: Running hbm2ddl schema update Apr 19, 2014 4:49:32 PM org.hibernate.tool.hbm2ddl.Schemaupdate execute INFO: HHH000102: Fetching database Metadata Apr 19, 2014 4:49:32 PM org.hibernate.tool.hbm2ddl.Schemaupdate execute INFO: HHH000396: Updating schema Apr 19, 2014 4:49:32 PM org.hibernate.tool.hbm2ddl.Tablemetadata INFO: HHH000261: Table found: public.pessoa Apr 19, 2014 4:49:32 pm org.hibernate.tool.hbm2ddl.Tablemetadata INFO: HHH000037: Columns: [id, idcidade_cidade, cep, id_cliente, idpessoa, nome, remarks, address] Apr 19, 2014 4:49:32 PM org.hibernate.tool.hbm2ddl.Tablemetadata INFO: HHH000108: Foreign Keys: [city_fk] Apr 19, 2014 4:49:32 PM org.hibernate.tool.hbm2ddl.Tablemetadata INFO: HHH000126: Indexes: [pkidpessoa] Apr 19, 2014 4:49:32 PM org.hibernate.tool.hbm2ddl.Schemaupdate execute INFO: HHH000232: Schema update complete Hibernate: select nextval ('hibernate_sequence') Hibernate: Insert into person (name, id) values (?, ?) Apr 19, 2014 4:49:32 PM org.hibernate.engine.jdbc.spi.Sqlexceptionhelper logExceptions WARN: SQL Error: 0, Sqlstate: 23502 Apr 19, 2014 4:49:32 PM org.hibernate.engine.jdbc.spi.Sqlexceptionhelper logExceptions ERROR: ERROR: null value in column "address" violates not-null Constraint
Detail: Failing Row contains (10, Andrades, null, null, null, 70, null). Exception in thread "main" javax.persistence.Rollbackexception: Error while committing the transaction at org.hibernate.ejb.TransactionImpl.commit(Transactionimpl.java:92) at testeUnite.ThesConnectedPortstgre.main(Testeconnectpostgre.java:19) Caused by: javax.persistence.Persistenceexception: org.hibernate.Exception.Constraintviolationexception: could not execute statement at org.hibernate.ejb.AbstractEntityManagerImpl.Convert(Abstractentitymanagerimpl.java:1387) at org.hibernate.ejb.AbstractEntityManagerImpl.Convert(Abstractentitymanagerimpl.java:1310) at org.hibernate.ejb.TransactionImpl.commit(Transactionimpl.java:80) ... 1 more Caused by: org.hibernate.Exception.Constraintviolationexception: could not execute statement at org.hibernate.Exception.internal.Sqlstateconversiondelegate.Convert(Sqlstateconversiondelegate.java:129) at org.hibernate.Exception.internal.Standardsqlexceptionconverter.Convert(Standardsqlexceptionconverter.java:49) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.Convert(Sqlexceptionhelper.java:125) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.Convert(Sqlexceptionhelper.java:110) at org.hibernate.engine.jdbc.Internal.ResultSetReturnImpl.executeUpdate(Resultsetreturnimpl.java:136) at org.hibernate.engine.jdbc.batch.internal.Nonbatchingbatch.addToBatch(Nonbatchingbatch.java:58) at org.hibernate.persister.entity.Abstractentitypersister.Insert(Abstractentitypersister.java:3067) at org.hibernate.persister.entity.Abstractentitypersister.Insert(Abstractentitypersister.java:3509) at org.hibernate.action.internal.Entityinsertaction.execute(Entityinsertaction.java:88) at org.hibernate.engine.spi.Actionqueue.execute(Actionqueue.java:377) at org.hibernate.engine.spi.Actionqueue.executeActions(Actionqueue.java:369) at org.hibernate.engine.spi.Actionqueue.executeActions(Actionqueue.java:286) at org.hibernate.Event.internal.Abstractflushingeventlistener.performExecutions(Abstractflushingeventlistener.java:339) at org.hibernate.Event.internal.Defaultflusheventlistener.onFlush(Defaultflusheventlistener.java:52) at org.hibernate.Internal.SessionImpl.flush(Sessionimpl.java:1234) at org.hibernate.Internal.SessionImpl.managedFlush(Sessionimpl.java:404) at org.hibernate.engine.transaction.Internal.jdbc.Jdbctransaction.beforeTransactionCommit(Jdbctransaction.java:101) at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(Abstracttransactionimpl.java:175) at org.hibernate.ejb.TransactionImpl.commit(Transactionimpl.java:75) ... 1 more Caused by: org.postgresql.util.Psqlexception: ERROR: null value in column "address" violates not-null Constraint Detail: Failing Row contains (10, Andrades, null, null, null, null, 70, null). at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(Queryexecutorimpl.java:2161) at org.postgresql.core.v3.QueryExecutorImpl.processResults(Queryexecutorimpl.java:1890) at org.postgresql.core.v3.QueryExecutorImpl.execute(Queryexecutorimpl.java:255) at org.postgresql.jdbc2.Abstractjdbc2statement.execute(Abstractjdbc2statement.java:559) at org.postgresql.jdbc2.Abstractjdbc2statement.executeWithFlags(Abstractjdbc2statement.java:417) at org.postgresql.jdbc2.Abstractjdbc2statement.executeUpdate(Abstractjdbc2statement.java:363) at org.hibernate.engine.jdbc.Internal.ResultSetReturnImpl.executeUpdate(Resultsetreturnimpl.java:133) ... 15 more
I believe the implementation is correct in my entity I put the following.
@Entity
@Table(name="person") public class Person Serializable{ private Static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE)
@Column(name="id")
private Long id;
public Long getId() {
return this.id;
}
private String nome;
//get and set
} I can’t understand why not insert, mysql is doing well but postgresql is not working.
my persistence
<?xml version="1.0" encoding="UTF-8"?>
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="comunicaVisual" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>entys.Pessoa</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost/postgres" />
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
<property name="javax.persistence.jdbc.user" value="postgres" />
<property name="javax.persistence.jdbc.password" value="1" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<prop
erty name="Hibernate.cache.use_query_cache" value="true" />
the image of the post
I hope someone can help.
opa blz friend, I have no address field I have only id and name.
– André Martins
I believe the problem may be in relation to persistence settings, because I did not put the scheme, but I do not know how to do it.
– André Martins
the address field error is in the error string Voce posted, ie probably the table in which Voce is trying to insert (or the entity class mapped in JPA) are with the address field. Read calmly and carefully the message that you will find the part of the message talking about the address field can not be null.
– Marcelo Bezerra bovino
your schema settings are using XML or Annotations?
– Marcelo Bezerra bovino
the configuration I made in the application is using XML
– André Martins
my entity...
– André Martins
do one thing, access your database using phpmyadmin or something like that, and confirm that in the table person there is no address field. if you want to export sql from table and post here we can see this for Voce.
– Marcelo Bezerra bovino
public class Pessoa Implements Serializable{ private Static final long serialVersionUID = 1L; @Id @Generatedvalue(Strategy=Generationtype.SEQUENCE) @Column(name="id") private Long id; public Long getId() ː Return this.id; } private String name; //get and set
– André Martins
I just took the name Entity and get them and set to post
– André Martins
Dude you were right I was worried about the application and I had forgotten about the comic, thank you very much.
– André Martins