Postgres und JPA - Primärschlüssel Problem

y0dA

Top Contributor
Hi!
Versuche gerade mit Hibernate, JPA2, JSF2 und Spring3 eine Webapplikation zu erstellen.
Momentan habe ich das Problem dass wenn ich den Server starte ich immer eine Exception bezüglich meiner einen Testklasse bekomme (entweder wird die Sequence nicht erkannt oder wenn ich kein @id angebe bekomme ich einen Fehler wie "kein identifier für Klasse Person" etc.).

Meine Frage, was benutzt ihr als Primary Key bei einer Postgres Datenbank? Habe den Datentyp "SERIAL" benutzt nur komme ich hierbei nicht zu einem erfolgreichen Start des Tomcats.

Hier mal ein paar Snippets:

Java:
-- Table: mybudgetschema."PERSON"

-- DROP TABLE mybudgetschema."PERSON";

CREATE TABLE mybudgetschema."PERSON"
(
  "ID" integer NOT NULL DEFAULT nextval('mybudgetschema."PERSON_ID_seq"'::regclass),
  "FIRSTNAME" character varying(30),
  "LASTNAME" character varying(30),
  CONSTRAINT "PK_PERSON" PRIMARY KEY ("ID")
)
WITH (
  OIDS=FALSE
);
ALTER TABLE mybudgetschema."PERSON" OWNER TO postgres;

Java:
@Entity
@Table(name = "PERSON")
public class Person {

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="PERSON_ID_seq")
	private Integer id;
	
	private String vorname;

	private String nachname;

service-spring.xml
Java:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="
            [url=http://www.springframework.org/schema/beans]Index of /schema/beans[/url]
            [url]http://www.springframework.org/schema/beans/spring-beans-3.0.xsd[/url]
            [url=http://www.springframework.org/schema/tx]Index of /schema/tx[/url]
            [url]http://www.springframework.org/schema/tx/spring-tx-3.0.xsd[/url]
            [url=http://www.springframework.org/schema/aop]Index of /schema/aop[/url]
            [url]http://www.springframework.org/schema/aop/spring-aop-3.0.xsd[/url]
            [url=http://www.springframework.org/schema/context]Index of /schema/context[/url]
            http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <!--
      Scan classpath for Spring components starting at base-package.
      Automatically inludes:
      - AutowiredAnnotationBeanPostProcessor
      - CommonAnnotationBeanPostProcessor
      -->
    <context:component-scan base-package="at.mpf.mybudget">
        <!-- <context:include-filter type="regex" expression=".service|.dao"/>  -->
    </context:component-scan>

    <!-- Enable processing of @PersistenceContext and @PersistenceUnit -->
    <context:annotation-config/>

    <!-- Enable transaction configuration with @Transactional -->
    <tx:annotation-driven transaction-manager="transactionManager"/>

    <!-- Configure a c3p0 pooled data source -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="user" value="postgres"/>
        <property name="password" value="postgres"/>
        <property name="driverClass" value="org.postgresql.Driver"/>
        <property name="jdbcUrl" value="jdbc:postgresql:mybudgetdb"/>
        <property name="initialPoolSize" value="1"/>
        <property name="minPoolSize" value="1"/>
        <property name="maxPoolSize" value="10"/>
    </bean>

    <!-- Configure the JPA entity manager factory with Hibernate -->
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource"/>

        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="showSql" value="false"/>
                <property name="database" value="HSQL"/>
                <property name="generateDdl" value="true"/>
            </bean>
        </property>

        <property name="persistenceUnitName" value="mybudget"/>
    </bean>

    <!-- Configure transaction manager for JPA -->
    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory"/>
    </bean>

</beans>

persistence.xml
Java:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
        version="1.0">

    <persistence-unit name="mybudget" transaction-type="RESOURCE_LOCAL">
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
            <property name="hibernate.show_sql" value="false" />
            <property name="hibernate.format_sql" value="false" />
            <property name="hibernate.use_sql_comments" value="false" />
            <property name="hibernate.connection.autocommit" value="false" />
            <property name="hibernate.cache.use_query_cache" value="false" />
            <property name="hibernate.cache.use_second_level_cache" value="false" />
            <property name="hibernate.hbm2ddl.auto" value="create" />
        </properties>

    </persistence-unit>
</persistence>

Fehler:
Java:
14.11.2010 14:11:18 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Development\tools\Java\jdk1.6.0_22\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files (x86)/Java/jre6/bin/client;C:/Program Files (x86)/Java/jre6/bin;C:/Program Files (x86)/Java/jre6/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Development\tools\apache-maven-2.2.1\bin;%JAVA_HOME%\bin
14.11.2010 14:11:18 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNUNG: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:MyBudgetWeb' did not find a matching property.
14.11.2010 14:11:18 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
14.11.2010 14:11:18 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 500 ms
14.11.2010 14:11:18 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
14.11.2010 14:11:18 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.29
14.11.2010 14:11:19 org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
14.11.2010 14:11:19 org.springframework.web.context.ContextLoader [main]
INFO  Root WebApplicationContext: initialization started
14.11.2010 14:11:19 org.springframework.web.context.support.XmlWebApplicationContext [main]
INFO  Refreshing Root WebApplicationContext: startup date [Sun Nov 14 14:11:19 CET 2010]; root of context hierarchy
14.11.2010 14:11:19 org.springframework.beans.factory.xml.XmlBeanDefinitionReader [main]
INFO  Loading XML bean definitions from ServletContext resource [/WEB-INF/web-spring.xml]
14.11.2010 14:11:19 org.springframework.context.annotation.ClassPathBeanDefinitionScanner [main]
INFO  JSR-330 'javax.inject.Named' annotation found and supported for component scanning
14.11.2010 14:11:19 org.springframework.beans.factory.xml.XmlBeanDefinitionReader [main]
INFO  Loading XML bean definitions from class path resource [service-spring.xml]
14.11.2010 14:11:19 org.springframework.context.annotation.ClassPathBeanDefinitionScanner [main]
INFO  JSR-330 'javax.inject.Named' annotation found and supported for component scanning
14.11.2010 14:11:19 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor [main]
INFO  JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
14.11.2010 14:11:19 org.springframework.beans.factory.support.DefaultListableBeanFactory [main]
INFO  Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@7b283052: defining beans [personBean,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,personService,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,dataSource,entityManagerFactory,transactionManager]; root of factory hierarchy
14.11.2010 14:11:19 com.mchange.v2.log.MLog [main]
INFO  MLog clients using log4j logging.
14.11.2010 14:11:19 com.mchange.v2.c3p0.C3P0Registry [main]
INFO  Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10]
14.11.2010 14:11:19 org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean [main]
INFO  Building JPA container EntityManagerFactory for persistence unit 'mybudget'
14.11.2010 14:11:20 org.hibernate.cfg.annotations.Version [main]
INFO  Hibernate Annotations 3.4.0.GA
14.11.2010 14:11:20 org.hibernate.cfg.Environment [main]
INFO  Hibernate 3.3.0.SP1
14.11.2010 14:11:20 org.hibernate.cfg.Environment [main]
INFO  hibernate.properties not found
14.11.2010 14:11:20 org.hibernate.cfg.Environment [main]
INFO  Bytecode provider name : javassist
14.11.2010 14:11:20 org.hibernate.cfg.Environment [main]
INFO  using JDK 1.4 java.sql.Timestamp handling
14.11.2010 14:11:20 org.hibernate.annotations.common.Version [main]
INFO  Hibernate Commons Annotations 3.1.0.GA
14.11.2010 14:11:20 org.hibernate.ejb.Version [main]
INFO  Hibernate EntityManager 3.4.0.GA
14.11.2010 14:11:20 org.hibernate.ejb.Ejb3Configuration [main]
INFO  Processing PersistenceUnitInfo [
	name: mybudget
	...]
14.11.2010 14:11:20 org.hibernate.cfg.AnnotationBinder [main]
INFO  Binding entity from annotated class: at.mpf.mybudget.domain.impl.Person
14.11.2010 14:11:20 org.hibernate.cfg.annotations.EntityBinder [main]
INFO  Bind entity at.mpf.mybudget.domain.impl.Person on table PERSON
14.11.2010 14:11:20 org.springframework.beans.factory.support.DefaultListableBeanFactory [main]
INFO  Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@7b283052: defining beans [personBean,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,personService,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,dataSource,entityManagerFactory,transactionManager]; root of factory hierarchy
14.11.2010 14:11:20 org.springframework.web.context.ContextLoader [main]
ERROR Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [service-spring.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unknown Id.generator: PERSON_ID_seq
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
	at org.apache.catalina.core.StandardService.start(StandardService.java:519)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.hibernate.AnnotationException: Unknown Id.generator: PERSON_ID_seq
	at org.hibernate.cfg.BinderHelper.makeIdGenerator(BinderHelper.java:428)
	at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1901)
	at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1279)
	at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:754)
	at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:546)
	at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:291)
	at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1148)
	at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1226)
	at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:173)
	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:854)
	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:425)
	at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:131)
	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
	... 27 more
14.11.2010 14:11:20 org.apache.catalina.core.StandardContext listenerStart
SCHWERWIEGEND: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [service-spring.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unknown Id.generator: PERSON_ID_seq
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
	at org.apache.catalina.core.StandardService.start(StandardService.java:519)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.hibernate.AnnotationException: Unknown Id.generator: PERSON_ID_seq
	at org.hibernate.cfg.BinderHelper.makeIdGenerator(BinderHelper.java:428)
	at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1901)
	at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1279)
	at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:754)
	at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:546)
	at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:291)
	at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1148)
	at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1226)
	at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:173)
	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:854)
	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:425)
	at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:131)
	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
	... 27 more
14.11.2010 14:11:20 com.sun.faces.config.ConfigureListener contextInitialized
INFO: Mojarra 2.0.1 (FCS b02) für Kontext '/MyBudgetWeb' wird initialisiert.
14.11.2010 14:11:21 com.sun.faces.config.ConfigureListener$WebConfigResourceMonitor$Monitor <init>
INFO: Monitoring jndi:/localhost/MyBudgetWeb/WEB-INF/faces-config.xml for modifications
14.11.2010 14:11:21 org.apache.catalina.core.StandardContext start
SCHWERWIEGEND: Error listenerStart
14.11.2010 14:11:21 org.apache.catalina.core.StandardContext start
SCHWERWIEGEND: Context [/MyBudgetWeb] startup failed due to previous errors
14.11.2010 14:11:21 org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
14.11.2010 14:11:21 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SCHWERWIEGEND: The web application [/MyBudgetWeb] registered the JBDC driver [org.postgresql.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
 
Zuletzt bearbeitet:
G

Gelöschtes Mitglied 5909

Gast
probiert mal

Java:
  @Id
  @SequenceGenerator(name="PersonSequence", sequenceName="PERSON_ID_seq")
  @GeneratedValue(generator="PersonSequence")
 

musiKk

Top Contributor
Für Postgres nehme ich immer [c]GenerationType.IDENTITY[/c]. Das habe ich irgendwann mal ergoogelt und damit gab es bei mir noch nie Probleme.
 

y0dA

Top Contributor
Danke für euer Unterstützung!

Hatte den Fehler schon kurz nach der Erstellung des Threads gefunden:

Java:
	@Id
	@SequenceGenerator(name = "SEQ_GEN_PERSON_ID_seq", sequenceName = "PERSON_ID_seq")
	@GeneratedValue(generator = "SEQ_GEN_PERSON_ID_seq", strategy = GenerationType.SEQUENCE)
	private Integer id;

Java:
	<!-- Configure the JPA entity manager factory with Hibernate -->
	<bean id="entityManagerFactory"
		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
		<property name="dataSource" ref="dataSource" />

		<property name="jpaVendorAdapter">
			<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
				<property name="database" value="POSTGRESQL" />
				<property name="databasePlatform" value="org.hibernate.dialect.PostgreSQLDialect" />
				<property name="showSql" value="true" />
				<property name="generateDdl" value="false" />

			</bean>
		</property>

		<property name="persistenceUnitName" value="mybudget" />
	</bean>
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
N Problem beim initialisieren des Caches Data Tier 0
S JPA Problem mit Cascading Data Tier 1
M Eclipse 4 RCP Hibernate Problem Data Tier 3
C JPA FetchType.LAZY, Relation @OneToMany und Problem mit dem update Data Tier 1
K Problem mit EJBs und Transaktionen Data Tier 0
G JPA: Entity Klasse @JoinColumns Problem Data Tier 2
M JPA Problem: java.sql.SQLSyntaxErrorException: Data Tier 7
H Hibernate Problem mit Lazy Loading bei @OneToMany Collections Data Tier 5
M MySql und JPA-Timestamp Problem Data Tier 8
J Hibernate Problem bei Master-Detail-Tabellen Data Tier 5
A JPA - ManyToMany Problem - keine Unique Mehrfachzuweisungen Data Tier 4
M Problem beim Laden von Objekten, die von anderen Applikationen in eine DB eingefügt wurden Data Tier 5
M Problem mit @Temporal Mapping und SQL Server Data Tier 3
P JPA - HashMap mit Many-to-Many Relation Problem Data Tier 4
B Problem mit @ManyToMany und CascadeType.ALL Data Tier 3
Blackskyliner [JPA][Anfänger] Problem mit Wertzuweisung aus Verbundtabelle Data Tier 2
B Problem mit org.hibernate.LazyInitializationException Data Tier 11
B DatenquellenUpdater extends Thread - Problem mit PermGenSpace Data Tier 5
S Problem beim Insert mit Hibernate Data Tier 9
Y [openJPA] Problem mit Transaktion? Data Tier 2
A @SecondaryTable Problem Data Tier 9
N Problem beim session.flush(); Data Tier 17
P SQL PRoblem Hibernate? Data Tier 8
Y EJB Problem mit Transaktionen Data Tier 7
M Transaction / Session Problem Data Tier 4
G JPA 2.0 Query Problem Data Tier 3
P CORBA Problem bei EJB 3.0 Anwendung in Glassfish v3 Data Tier 7
F Problem mit Hibernate Schema Update Data Tier 2
S Lazy loading Problem Data Tier 2
M Insert-Problem mit JPA/Hibernate Data Tier 4
megachucky JPA - Problem mit Persistence Unit / Context Data Tier 1
H Hibernate Problem Data Tier 4
D Performance Problem mit Prepared Statement Data Tier 6
T Problem mit openJPA Data Tier 7
P Problem mit Data Tier 9
GilbertGrape Cascade Problem (Hibernate) Data Tier 3
C JPA Problem mit attributeOverride und mehrspaltigem PK Data Tier 2
B select "neu" statement Problem (jpql) Data Tier 8
boxi Hibernate Lazy Loading Problem Data Tier 2
M Problem mit Hibernate und SLF4J - NoSuchMethodException Data Tier 3
G Connection Problem - WAS 6.1, Hibernate, OS Authentication Data Tier 1
K Hibernate update-Problem Data Tier 36
J hibernate problem Data Tier 14
N Hibernate - Problem mit Update/Insert Data Tier 4
B Problem mit @PersistenceContext Data Tier 4
G Problem with mapped of the tables at one to one relationship Data Tier 8

Ähnliche Java Themen


Oben