Ola colegas, estou com um problema no momento que executomeu script no net beans.
Vejam o cod:
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
@Entity
@Table(name="cad_produtos")
/**
*
* @author
*/
public class cls_cad_produtos implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(columnDefinition="prod_cod")
private Integer prod_cod;
@Column( columnDefinition="cod_prod")
private String prod_descricao;
public Integer getProd_cod() {
return prod_cod;
}
public void SetProd_cod(Integer Prrod_cod) {
prod_cod=Prrod_cod;
}
public String getProd_descricao() {
return prod_descricao;
}
public void SetProd_descricao(String Prod_desc) {
prod_descricao=Prod_desc;
}
}
import javax.swing.*;
import org.hibernate.*;
import org.hibernate.cfg.AnnotationConfiguration;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author
*/
public class cls_prs_cad_produtos {
public static void main(String [] args){
try{
AnnotationConfiguration cfg = new AnnotationConfiguration();
cfg.addAnnotatedClass(cls_cad_produtos.class);
SessionFactory fabrica = cfg.buildSessionFactory();
Session sessao = fabrica.openSession();
cls_cad_produtos obj_cls_cad_produtos = new cls_cad_produtos();
obj_cls_cad_produtos.SetProd_descricao("descricao teste annotation");
Transaction tx_cad_produtos = sessao.beginTransaction();
sessao.save(obj_cls_cad_produtos);
tx_cad_produtos.commit();
sessao.close();
}
catch(Exception erro)
{
}
}
}
0 [main] INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.4.0.GA
16 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.0.SP1
32 [main] INFO org.hibernate.cfg.Environment - loaded properties from resource hibernate.properties: {hibernate.pool_size=10, hibernate.connection.driver_class=org.gjt.mm.mysql.Driver, hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect, hibernate.format_sql=true, hibernate.connection.username=root, hibernate.hbm2ddl.auto=create;, hibernate.connection.url=jdbc:mysql://localhost:3306/constricomp, hibernate.bytecode.use_reflection_optimizer=false, hibernate.show_sql=true, hibernate.connection.password=****}
32 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
47 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
141 [main] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.1.0.GA
172 [main] INFO org.hibernate.cfg.search.HibernateSearchEventListenerRegister - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
266 [main] INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: cls_cad_produtos
328 [main] INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity cls_cad_produtos on table cad_produtos
391 [main] INFO org.hibernate.cfg.AnnotationConfiguration - Hibernate Validator not found: ignoring
500 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
500 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
500 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
516 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost:3306/constricomp
516 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=root, password=****}
1047 [main] INFO org.hibernate.cfg.SettingsFactory - RDBMS: MySQL, version: 5.1.45-community
1047 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.12 ( Revision: ${bzr.revision-id} )
1063 [main] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.PostgreSQLDialect
1063 [main] INFO org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions)
1063 [main] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
1063 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
1063 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
1063 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
1063 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
1063 [main] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
1063 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): enabled
1063 [main] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
1063 [main] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
1063 [main] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
1078 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
1078 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
1078 [main] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
1078 [main] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
1078 [main] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
1078 [main] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
1078 [main] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
1078 [main] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
1078 [main] INFO org.hibernate.cfg.SettingsFactory - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
1078 [main] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
1078 [main] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
1094 [main] INFO org.hibernate.cfg.SettingsFactory - Echoing all SQL to stdout
1094 [main] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
1094 [main] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
1094 [main] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
1094 [main] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
1157 [main] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
1453 [main] INFO org.hibernate.impl.SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
Hibernate:
select
nextval ('hibernate_sequence')
1578 [main] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 1305, SQLState: 42000
1578 [main] ERROR org.hibernate.util.JDBCExceptionReporter - FUNCTION constricomp.nextval does not exist
CONSTRUÍDO COM SUCESSO (tempo total: 1 segundo)
Qual o problema que esta ocorrendo ? no banco de dados (mysql ) ja esta autoincremento...
alguem sabe oque é ?
sds,
