Sorry, it sent the mail too early....

As I said, I wrote a jdo-conf.xml file compatible with my database and I'm
now trying to make the interact.
I wrote a little main which instanciates a person and tries to put it in the
database.
This is the code trying to save a person in the database (the person object
is called single).

*try
{
db=manag.getDatabase();
db.begin();
System.out.println("On a prepare");
}
catch(Exception e)
{ e.printStackTrace(); }

this.getCastorTemplate().create(single);
try
{
db.commit();
db.close();
}
catch(Exception e)
  { e.printStackTrace(); }
*

But every time, I get the Java Exception: No transaction in progress.
But I am instanciating the database and I begin the transaction before I try
to save.........

Does anyone know a solution to that ?

Best regards,
Jorrit Wortel

2010/5/28 Jorrit Wortel <[email protected]>

> Hei,
>
> I changed my classes and almost everything is alright now.
>
> The only problem is the database.
> I wrote
>
> 2010/5/28 Lukas Lang <[email protected]>
>
> Hey Jorrit,
>>
>> the reason for your compile-time errors is the following, I guess: We are
>> not shipping the JPA annotations, the persistence API Jar to be more
>> specific, with Castor, as for example some Servlet containers have provide
>> it, thus it would be loaded twice (sealing violation). The simple solution
>> to your problem is putting the Sun persistence API (aka JPA annotations) on
>> the classpath. Ether by doing so manually or adding it as a Maven dependency
>> in case you are using Maven. You can download the API from [1].
>>
>> Good luck!
>>
>> Regards,
>> Lukas
>>
>> [1]
>> http://mvnrepository.com/artifact/javax.persistence/persistence-api/1.0
>>
>> Am 28.05.2010 um 10:20 schrieb Jorrit Wortel:
>>
>> Hi,
>>
>> First of all, thank you for your information !
>>
>> But I still have a problem. It is a package problem I suppose.
>>
>> I'm using the JPA annotations in a class (Person.java).
>> I did big imports to try making it compile:
>> - org.castor.jdo.jpa.info.*;
>> - org.castor.jdo.jpa.natures.*;
>> - org.castor.jdo.jpa.processors.*;
>> I even added these ones:
>> org.castor.jdo.jpa.processors.fieldprocessors.*;
>> org.castor.jdo.jpa.processors.classprocessors.*;
>>
>> But when I'm compiling, I get the following errors :
>> *Person.java:8: cannot find symbol*
>> *symbol: class Entity*
>> *...@entity*
>> * ^*
>> * Person.java:9: cannot find symbol*
>> *symbol: class Table*
>> *...@table(name="person")*
>> * ^*
>> *Person.java:13: cannot find symbol*
>> *symbol : class Id*
>> *location: class Person*
>> * @Id*
>> * ^*
>> *Person.java:14: cannot find symbol*
>> *symbol : class Column*
>> *location: class Person*
>> * @Column(name="nom")*
>> * ^*
>> *Person.java:17: cannot find symbol*
>> *symbol : class Column*
>> *location: class Person*
>>
>> For more comprehension, The class I try to compile is as joined.
>>
>> Could someone help me ? I don't understand why it is not compiling. From
>> the javadoc of the fieldprocessors package, I understood that it is that
>> package that has to process the JPA annotations.....
>>
>> Best regards,
>> Jorrit Wortel
>>
>> 2010/5/26 Lukas Lang <[email protected]>
>>
>> @Column(name="age")
>>
>>
>>
>> Hey Jorrit,
>>>
>>> it's great to see you making progress! I'll try to give you a short and
>>> simple answer:
>>> Since the JDOManager is managed and instantiated by your IoC container
>>> (Spring), this piece of code is already implemented by Castor. Just wire
>>> everything up as in the example on the website [1].
>>> Let us know if you can fix it!
>>>
>>> Best,
>>> Lukas
>>>
>>> [1] http://castor.codehaus.org/reference/html/jpa.html#d0e8744
>>>
>>>
>>>
>>> Am 26.05.2010 um 16:00 schrieb Jorrit Wortel:
>>>
>>> Hello everyone,
>>>
>>> After having (successfully) Marshalled and Unarshalled data from XML to
>>> Java and from Java to XML, I'm now trying to make things a bit harder: I'm
>>> adding the relational database.
>>>
>>> That is, I'm trying to pass data from an XML (or java, doesn't matter) to
>>> a relational database.
>>> I did the following (conforming to the doc):
>>> - Adding the JPA annotations to my class (Person.java)
>>> - Implementing the CastorDaoSupport with its interface (the same way it
>>> has been done in the doc)
>>> - Creating a spring-config.xml
>>> - Creating a jdo-conf.xml
>>>
>>> But in the doc it is said I have to add this piece of code :
>>> *JDOClassDescriptorResolver resolver = new
>>> JDOClassDescriptorResolverImpl();
>>> resolver.addClass(org.castor.jpa.Single.class);
>>> // or alternatively you can add the package:
>>> resolver.addPackage("org.castor.jpa");
>>>
>>> InputSource jdoConfiguration = ...;
>>> JDOManager.loadConfiguration(jdoConfiguration, null, null, resolver);
>>>
>>> JDOManager jdoManager = JDOManager.createInstance("jpa-extensions");
>>> *
>>>
>>> The only point is: where do I have to add it ???
>>>
>>> It seems to be Java code but in wich class file do I have to put it ?
>>>
>>> If anyone could help me, that would be very appreciated !
>>>
>>> Best regards,
>>> Jorrit Wortel
>>>
>>>
>>>
>>
>

Reply via email to