- This topic has 10 replies, 2 voices, and was last updated 17 years, 6 months ago by Riyad Kalla.
-
AuthorPosts
-
maximuszenMemberI have a EJB 3 entity bean. How do I write a persistence.xml for it? I’m using postgres, hibernate.
Riyad KallaMemberMaximumszen,
If you created an EJB 3 project, during the project-creation step, you should have been asked to configure the persistence information for the project. In MyEclipse 6.0 we will provide facilities to generate persistence units for you after the project has been created.
maximuszenMemberwhen will eclipse 6 be out
Riyad KallaMemberIf you mean MyEclipse 6.0, it will be out next month.
maximuszenMemberwhen i try to reverse engineer a table to ejb 3 it asks for the source folder for whatever reason i get no choices for a sorce folder despite having one in my ejb progject src
Riyad KallaMemberThat could be for a couple of reasons:
1) Your project is not an EJB (Java EE 5/EJB 3) Project.
2) Your project is a plain Web Project or Java project.
3) Your project doesn’t have JPA Capabilities added to it (implied by #1)
maximuszenMemberThank you. I did it yesterday and…
maximuszenMemberThis is my persistence.xml
<?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=”p” transaction-type=”JTA”>
<jta-data-source>java:/PostgresDS</jta-data-source>
<properties>
<property name=”hibernate.hbm2ddl.auto” value=”update” />
</properties>
</persistence-unit></persistence>
but I get the error below
14:20:52,265 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.entity.PersistenceUnitDeployment
14:20:52,265 INFO [JmxKernelAbstraction] installing MBean: persistence.units:jar=Test.jar,unitName=p with dependencies:
14:20:52,265 INFO [JmxKernelAbstraction] jboss.jca:name=PostgresDS,service=DataSourceBinding
14:20:52,281 INFO [PersistenceUnitDeployment] Starting persistence unit persistence.units:jar=Test.jar,unitName=p
14:20:52,296 INFO [Ejb3Configuration] found EJB3 Entity bean: ejb.T2
14:20:52,312 INFO [Ejb3Configuration] found EJB3 Entity bean: ejb.T3
14:20:52,312 WARN [Ejb3Configuration] Persistence provider caller does not implements the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null.
14:20:52,343 INFO [Configuration] Reading mappings from resource : META-INF/orm.xml
14:20:52,343 INFO [Ejb3Configuration] [PersistenceUnit: p] no META-INF/orm.xml found
14:20:52,359 INFO [AnnotationBinder] Binding entity from annotated class: ejb.T2
14:20:52,359 INFO [EntityBinder] Bind entity ejb.T2 on table t2
14:20:52,359 INFO [AnnotationBinder] Binding entity from annotated class: ejb.T3
14:20:52,359 INFO [EntityBinder] Bind entity ejb.T3 on table T3
14:20:52,390 INFO [ConnectionProviderFactory] Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
14:20:52,390 INFO [InjectedDataSourceConnectionProvider] Using provided datasource
14:20:52,390 INFO [SettingsFactory] RDBMS: PostgreSQL, version: 8.2.4
14:20:52,390 INFO [SettingsFactory] JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.2 JDBC3 with SSL (build 505)
14:20:52,390 INFO [Dialect] Using dialect: org.hibernate.dialect.PostgreSQLDialect
14:20:52,390 INFO [TransactionFactoryFactory] Transaction strategy: org.hibernate.ejb.transaction.JoinableCMTTransactionFactory
14:20:52,390 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
14:20:52,390 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
14:20:52,390 INFO [SettingsFactory] Automatic flush during beforeCompletion(): disabled
14:20:52,390 INFO [SettingsFactory] Automatic session close at end of transaction: disabled
14:20:52,390 INFO [SettingsFactory] JDBC batch size: 15
14:20:52,390 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
14:20:52,390 INFO [SettingsFactory] Scrollable result sets: enabled
14:20:52,390 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
14:20:52,390 INFO [SettingsFactory] Connection release mode: auto
14:20:52,390 INFO [SettingsFactory] Default batch fetch size: 1
14:20:52,390 INFO [SettingsFactory] Generate SQL with comments: disabled
14:20:52,390 INFO [SettingsFactory] Order SQL updates by primary key: disabled
14:20:52,390 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
14:20:52,390 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
14:20:52,390 INFO [SettingsFactory] Query language substitutions: {}
14:20:52,390 INFO [SettingsFactory] JPA-QL strict compliance: enabled
14:20:52,390 INFO [SettingsFactory] Second-level cache: enabled
14:20:52,390 INFO [SettingsFactory] Query cache: disabled
14:20:52,390 INFO [SettingsFactory] Cache provider: org.hibernate.cache.HashtableCacheProvider
14:20:52,390 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
14:20:52,390 INFO [SettingsFactory] Cache region prefix: Test_jar,p
14:20:52,390 INFO [SettingsFactory] Structured second-level cache entries: disabled
14:20:52,390 INFO [SettingsFactory] Statistics: disabled
14:20:52,390 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
14:20:52,390 INFO [SettingsFactory] Default entity-mode: pojo
14:20:52,390 INFO [SettingsFactory] Named query checking : enabled
14:20:52,390 INFO [SessionFactoryImpl] building session factory
14:20:52,437 INFO [SessionFactoryObjectFactory] Factory name: persistence.units:jar=Test.jar,unitName=p
14:20:52,437 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
14:20:52,437 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: persistence.units:jar=Test.jar,unitName=p
14:20:52,437 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext
14:20:52,468 INFO [SchemaUpdate] Running hbm2ddl schema update
14:20:52,468 INFO [SchemaUpdate] fetching database metadata
14:20:52,531 INFO [SchemaUpdate] updating schema
14:20:52,593 INFO [DatabaseMetadata] table not found: T3
14:20:52,625 INFO [DatabaseMetadata] table not found: t2
14:20:52,625 INFO [DatabaseMetadata] table not found: T3
14:20:52,625 INFO [DatabaseMetadata] table not found: t2
14:20:52,625 INFO [DatabaseMetadata] table not found: hibernate_sequence
14:20:52,703 INFO [SchemaUpdate] schema update complete
14:20:52,703 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
14:20:52,718 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
14:20:52,718 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=Test.jar,name=T2Facade,service=EJB3 with dependencies:
14:20:52,718 INFO [JmxKernelAbstraction] persistence.units:jar=Test.jar,unitName=p
14:20:52,750 INFO [EJBContainer] STARTED EJB: ejb.T2Facade ejbName: T2Facade
14:20:52,875 INFO [EJB3Deployer] Deployed: file:/C:/Program Files/jboss-4.2.0.GA/server/default/deploy/Test.jar/
maximuszenMemberT3
package ejb;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class T3 {@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String t;public T3(String t) {
this.t = t;
}public T3() {
}public Long getId() {
return this.id;
}public void setId(Long id) {
this.id = id;
}public int hashCode() {
return (this.id == null) ? 0 : this.id.hashCode();
}public boolean equals(Object object) {
if (object instanceof T3) {
final T3 obj = (T3) object;
return (this.id != null) ? this.id.equals(obj.id)
: (obj.id == null);
}
return false;
}public String getT() {
return t;
}public void setT(String t) {
this.t = t;
}}
maximuszenMemberT2.java this was ejb3 reengineered from table t2
package ejb;
// default packageimport javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;/**
* T2 generated by MyEclipse Persistence Tools
*/
@Entity
@Table(name=”t2″
,schema=”public”
, uniqueConstraints = { }
)public class T2 implements java.io.Serializable {
// Fields
private Integer id;
private String t;// Constructors
/** default constructor */
public T2() {
}/** minimal constructor */
public T2(Integer id) {
this.id = id;
}/** full constructor */
public T2(Integer id, String t) {
this.id = id;
this.t = t;
}// Property accessors
@Id@Column(name=”id”, unique=true, nullable=false, insertable=true, updatable=true)
public Integer getId() {
return this.id;
}public void setId(Integer id) {
this.id = id;
}@Column(name=”t”, unique=false, nullable=true, insertable=true, updatable=true)
public String getT() {
return this.t;
}public void setT(String t) {
this.t = t;
}}
Riyad KallaMemberNotice the error, says the spec provider doesn’t implement something correctly, and I noticed you are using Hibernate. Try reconfiguring the project to use Toplink instead of Hibernate.
-
AuthorPosts