I made some changes since my last post, I have replaced
'Neo4jConfiguration' with 'CrossStoreNeo4jConfiguration' (see code below),
however the Exception is the same "hibernate MappingException: Could not
determine type for: java.util.Set" ( still remains (see original post
below). Any feedback yo may have will be of much help.
Original post;
I have a Jpa entity which also acts as a Neo4j cross store. Most of the
fields in the entity are saved to Mysql database except the Collection
'followers', which is stored in Neo4j. The problem is with the Collection
'followers'. it throws the exception "hibernate MappingException: Could not
determine type for: java.util.Set". A quick search yields a bunch of Jpa
Related solutions (e.g. adding onetomany annotation to the field etc) which
I assume is not relevant in this case because the collection is saved in
Neo4j not Mysql.
Stacktrace
Caused by: org.hibernate.MappingException: Could not determine type for:
java.util.Set, at table: game, for columns:
[org.hibernate.mapping.Column(followers)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:314)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:292)
at org.hibernate.mapping.Property.isValid(Property.java:239)
at
org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:469)
at org.hibernate.mapping.RootClass.validate(RootClass.java:270)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1303)
at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1761)
at
org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96)
at
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
... 16 more
-------
@Entity
@Table(name="game")
@NodeEntity(partial = true)
public class Game implements Serializable{
private static final long serialVersionUID = 1L;
@RelatedTo(type="GAME", direction=Direction.INCOMING, elementClass =
Account.class)
@Fetch
@GraphProperty
private Set<Account> followers = new HashSet<Account>();
@Id
@GeneratedValue(strategy=IDENTITY)
@Column(name="game_id")
private Long gameId;
@Column(name="name",unique=true)
private String name;
....
//Accessors
public Long getGameId() {
return gameId;
}
public void setGameId(Long gameId) {
this.gameId = gameId;
}
...
@Override
public String toString(){
return "...";
}
}
//Jpa Setup
@Configuration
@EnableTransactionManagement(mode=AdviceMode.ASPECTJ)
@EnableJpaRepositories(value={"com.repository"},
entityManagerFactoryRef="entityManagerFactory",
transactionManagerRef="transactionManager")
@PropertySource("classpath:db.properties")
public class JpaConfig {
@Autowired
private Environment environment;
@Bean
public PlatformTransactionManager transactionManager() {
JpaTransactionManager txManager = new JpaTransactionManager();
txManager.setEntityManagerFactory((EntityManagerFactory)
entityManagerFactory());
return txManager;
}
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean factory = new
LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
factory.setPackagesToScan("com.equitytwits.core");
factory.setJpaPropertyMap(AppUtil.jpaProperties());
factory.setDataSource(dataSource());
return factory;
}
@Bean
public DriverManagerDataSource dataSource(){
DriverManagerDataSource driverManagerDataSource = new
DriverManagerDataSource();
driverManagerDataSource.setDriverClassName(environment.getRequiredProperty("jdbc.driverClassName"));
driverManagerDataSource.setUrl(environment.getRequiredProperty("jdbc.url"));
driverManagerDataSource.setUsername(environment.getRequiredProperty("jdbc.username"));
driverManagerDataSource.setPassword(environment.getRequiredProperty("jdbc.password"));
return driverManagerDataSource;
}
}
//Neo4j Setup
@Configuration
@ComponentScan(basePackages={"..."})
@EnableTransactionManagement(mode=AdviceMode.ASPECTJ)
@EnableNeo4jRepositories(value={"..."})
public class Neo4JConfig extends CrossStoreNeo4jConfiguration{
@Bean(destroyMethod = "shutdown")
@Scope(SCOPE_PROTOTYPE)
public SpringRestGraphDatabase graphDatabaseService(){
SpringRestGraphDatabase springRestGraphDatabase = new
SpringRestGraphDatabase("http://localhost:7474/db/data");
return springRestGraphDatabase;
}
@Bean
public Neo4jTemplate neo4jTemplate(){
return new Neo4jTemplate((GraphDatabase) graphDatabaseService());
}
@Bean
public Neo4jMappingContext neo4jMappingContext() {
return new Neo4jMappingContext();
}
}
--
You received this message because you are subscribed to the Google Groups
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.