我试图连接到Neo4j数据库。我的数据库是从Neo4j网站下载的#Cineacts Actors& Movies"。 它位于C:\ NewMovies
这是我的申请:
public class App
{
private static final String JBOSS_TM_CLASS_NAME = "com.arjuna.ats.jta.TransactionManager";
public static void main( String[] args )
{
TransactionManager tm = getTransactionManager();
//build the EntityManagerFactory as you would build in in Hibernate Core
EntityManagerFactory emf = Persistence.createEntityManagerFactory("ogm-jpa-tutorial");
System.out.println( "Hello World!" );
}
public static TransactionManager getTransactionManager() {
try {
Class<?> tmClass = App.class.getClassLoader().loadClass( JBOSS_TM_CLASS_NAME );
return (TransactionManager) tmClass.getMethod( "transactionManager" ).invoke( null );
} catch ( ClassNotFoundException e ) {
e.printStackTrace();
} catch ( InvocationTargetException e ) {
e.printStackTrace();
} catch ( NoSuchMethodException e ) {
e.printStackTrace();
} catch ( IllegalAccessException e ) {
e.printStackTrace();
}
return null;
}
}
我的持久性文件:
<?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_2_0.xsd"
version="2.0">
<persistence-unit name="ogm-jpa-tutorial" transaction-type="JTA">
<!-- Use Hibernate OGM provider: configuration will be transparent -->
<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
<class>com.mycompany.hibernateneo.Movie</class>
<properties>
<property name="hibernate.ogm.datastore.provider" value="neo4j_embedded" />
<property name="hibernate.ogm.neo4j.database_path" value="C:/NewMovies" />
<!-- defines which JTA Transaction we plan to use -->
<property name="hibernate.transaction.jta.platform"
value="org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform"/>
</properties>
</persistence-unit>
</persistence>
我的实体档案:
@Entity
@Table(name = "Movie")
public class Movie {
@Id
String id;
@Basic
String title;
@Basic
String description;
@Basic
private String language;
@Basic
private String imdbId;
@Basic
private String tagline;
@Basic
private Integer runtime;
@Basic
private String homepage;
@Basic
private String trailer;
@Basic
private String genre;
@Basic
private String studio;
@Basic
private Integer version;
@Basic
private String imageUrl;
public Movie() {
}
public Movie(String id, String title) {
this.id = id;
this.title = title;
}
public String getId() {
return id;
}
public String getTitle() {
return title;
}
public String getDescription() {
return description;
}
public void setTitle(String title) {
this.title=title;
}
public void setLanguage(String language) {
this.language = language;
}
public void setImdbId(String imdbId) {
this.imdbId = imdbId;
}
public void setTagline(String tagline) {
this.tagline = tagline;
}
public void setDescription(String description) {
this.description = description;
}
public void setRuntime(Integer runtime) {
this.runtime = runtime;
}
public void setHomepage(String homepage) {
this.homepage = homepage;
}
public void setTrailer(String trailer) {
this.trailer = trailer;
}
public void setGenre(String genre) {
this.genre = genre;
}
public void setStudio(String studio) {
this.studio = studio;
}
public void setVersion(Integer version) {
this.version = version;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getLanguage() {
return language;
}
public String getImdbId() {
return imdbId;
}
public String getTagline() {
return tagline;
}
public Integer getRuntime() {
return runtime;
}
public String getHomepage() {
return homepage;
}
public String getTrailer() {
return trailer;
}
public String getGenre() {
return genre;
}
public String getStudio() {
return studio;
}
public Integer getVersion() {
return version;
}
public String getImageUrl() {
return imageUrl;
}
public String getYoutubeId() {
String trailerUrl = trailer;
if (trailerUrl==null || !trailerUrl.contains("youtu")) return null;
String[] parts = trailerUrl.split("[=/]");
int numberOfParts = parts.length;
return numberOfParts > 0 ? parts[numberOfParts-1] : null;
}
}
我得到的错误:
线程中的异常&#34; main&#34; javax.persistence.PersistenceException:[PersistenceUnit:ogm-jpa-tutorial]无法构建EntityManagerFactory 在org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915) 在org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890) 在org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57) 在org.hibernate.ogm.jpa.HibernateOgmPersistence.createEntityManagerFactory(HibernateOgmPersistence.java:93) 在javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) 在javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) 在com.mycompany.hibernateneo.App.main(App.java:22) 引起:org.hibernate.MappingException:无法获取org.hibernate.ogm.persister.SingleTableOgmEntityPersister的构造函数 在org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:185) 在org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:135) 在org.hibernate.internal.SessionFactoryImpl。(SessionFactoryImpl.java:385) 在org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1742) 在org.hibernate.ejb.EntityManagerFactoryImpl。(EntityManagerFactoryImpl.java:94) 在org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905) ......还有6个 引起:org.hibernate.service.spi.ServiceException:无法创建请求的服务[org.hibernate.ogm.dialect.impl.GridDialectFactory] at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:186) 在org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:150) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) at org.hibernate.ogm.datastore.impl.DatastoreServicesInitiator.initiateService(DatastoreServicesInitiator.java:50) at org.hibernate.ogm.datastore.impl.DatastoreServicesInitiator.initiateService(DatastoreServicesInitiator.java:39) at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.initiateService(SessionFactoryServiceRegistryImpl.java:91) at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:176) 在org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:150) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) 在org.hibernate.ogm.persister.OgmEntityPersister。(OgmEntityPersister.java:129) 在org.hibernate.ogm.persister.SingleTableOgmEntityPersister。(SingleTableOgmEntityPersister.java:47) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) 在org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:163) ......还有11个 引起:java.lang.IllegalArgumentException:属性hibernate.ogm.neo4j.database.path不能为null at org.hibernate.ogm.datastore.neo4j.impl.EmbeddedGraphDatabaseFactory.validate(EmbeddedGraphDatabaseFactory.java:61) 在org.hibernate.ogm.datastore.neo4j.impl.EmbeddedGraphDatabaseFactory.initialize(EmbeddedGraphDatabaseFactory.java:52) 在org.hibernate.ogm.datastore.neo4j.impl.Neo4jGraphDatabaseServiceFactoryProvider.load(Neo4jGraphDatabaseServiceFactoryProvider.java:44) 在org.hibernate.ogm.datastore.neo4j.impl.Neo4jDatastoreProvider.configure(Neo4jDatastoreProvider.java:77) at org.hibernate.ogm.service.impl.OgmSessionFactoryServiceRegistryImpl.configureService(OgmSessionFactoryServiceRegistryImpl.java:69) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) 在org.hibernate.ogm.dialect.impl.GridDialectFactoryInitiator.createDialect(GridDialectFactoryInitiator.java:58) 在org.hibernate.ogm.dialect.impl.GridDialectFactoryInitiator.initiateService(GridDialectFactoryInitiator.java:49) 在org.hibernate.ogm.dialect.impl.GridDialectFactoryInitiator.initiateService(GridDialectFactoryInitiator.java:38) at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.initiateService(SessionFactoryServiceRegistryImpl.java:91) at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:176) ......还有26个
拜托,任何想法?
答案 0 :(得分:1)
删除
<property name="hibernate.transaction.jta.platform"
value="org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform"/>
来自persistence.xml文件的。 HibernateOGM for neo4j目前在OGM内部使用一种变通解决方案进行交易。
现在反映在最新的beta手册中。 Look at the Warning box