Search code examples
mongodbkunderanosql

Persistence unit for class issue


I am using Kundera with mongodb on a windows 7 box. I am trying to use int data type. But I am getting the following error.

Exception in thread "main" com.impetus.kundera.configure.schema.SchemaGenerationException: Persistence unit for class : int is not loaded
    at com.impetus.kundera.configure.SchemaConfiguration.parseRelations(SchemaConfiguration.java:262)
    at com.impetus.kundera.configure.SchemaConfiguration.configure(SchemaConfiguration.java:151)
    at com.impetus.kundera.configure.ClientMetadataBuilder.buildClientFactoryMetadata(ClientMetadataBuilder.java:48)
    at com.impetus.kundera.persistence.EntityManagerFactoryImpl.configureClientFactories(EntityManagerFactoryImpl.java:404)
    at com.impetus.kundera.persistence.EntityManagerFactoryImpl.configure(EntityManagerFactoryImpl.java:157)
    at com.impetus.kundera.persistence.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:131)
    at com.impetus.kundera.KunderaPersistence.createEntityManagerFactory(KunderaPersistence.java:85)
    at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
    at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
    at com.atomconnect.App.insertIntoMongo(App.java:37)
    at com.atomconnect.App.main(App.java:53)

My entity object has the following fields

@Id
@Column(name="MESSAGE_ID")
private String messageId;

@Column(name = "SUBJECT")
private String subject;

@Column(name = "BODY")
private String body;

@Column(name = "zipcode")
private int zipcode;

@Embedded
private Contact from;

My persistence.xml looks like below

<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="2.0">
<persistence-unit name="ac">
    <provider>com.impetus.kundera.KunderaPersistence</provider>
    <properties>
        <property name="kundera.nodes" value="localhost" />
        <property name="kundera.port" value="12345" />
        <property name="kundera.keyspace" value="test" />
        <property name="kundera.dialect" value="mongodb" />
        <property name="kundera.client.lookup.class" value="com.impetus.client.mongodb.MongoDBClientFactory" />
        <property name="" value="datastore_mongo.jar"/>
       <!--  <property name="kundera.cache.provider.class" value="com.impetus.kundera.cache.ehcache.EhCacheProvider" />
        <property name="kundera.cache.config.resource" value="/ehcache-test.xml" /> -->
    </properties>
    <jar-file>target/test.jar</jar-file>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
 </persistence-unit>
</persistence>

I wasted 2 days around this but not able to get the solution. Any help would be appreciated


Solution

  • I had a class for which I have declared the one to one mapping annotation for a int data type which was never used.

    This should not cause any problem but the way kundera populates metadata via reflection is the issue.