Re: error writing tuple to database the owning entity is not mapped geronimo 2.1.1

2008-07-07 Thread Mario Kofler
hi jacek,

thanks for your help, i did change my birthdate field to sql.Date now.
the error message remains. but i realized, that the error message just
appears at the first write operation: all following write operations
are executed successfully. i will try to make my tests, i think i'll
just ignore the first write action and start my tests from the 2nd
write operation on.

for the moment, thanks!

mario.

2008/7/6 Jacek Laskowski [EMAIL PROTECTED]:
 On Sun, Jul 6, 2008 at 11:34 AM, Mario Kofler [EMAIL PROTECTED] wrote:


 Hi Mario,

 Let's make it simpler by removing some unneeded, defaulted
 configuration values in your sample.

 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/persistence_1_0.xsd;
 version=1.0
  persistence-unit name=valhalla transaction-type=JTA

 Hint: you may remove transaction-type as it's JTA in managed
 environment like Geronimo.

descriptionvideothek/description

 providerorg.apache.openjpa.persistence.PersistenceProviderImpl/provider

 Provider defaults to openjpa in Geronimo. You may remove it.

classvt.bean.entity.Person/class
classvt.bean.entity.Actor/class
classvt.bean.entity.Director/class
classvt.bean.entity.Movie/class
classvt.bean.entity.Dvd/class

 Not needed in managed environment like Geronimo. It makes things run
 faster - no need to look for annotated classes, but am not sure if we
 don't do this even though the class elements are specified.

 Also, you showed Person entity class, but what about the rest? Either
 remove them and let's play with a single entity only and add more
 later or show all of them as I think the issue might be in the others.

properties

  property name=openjpa.jdbc.DBDictionary value=postgres/
  !--property name=openjpa.LockManager value=pessimistic/--
/properties
jta-data-sourcejdbc/postgres/jta-data-source
non-jta-data-sourcejdbc/postgres/non-jta-data-source

 I think *data-source should be before properties element. Geronimo
 should really be more strict.

 @Entity
 @Table(name=person)
 @Inheritance(strategy=InheritanceType.JOINED)
 @DiscriminatorColumn(name=role, discriminatorType=DiscriminatorType.STRING)

 discriminatorType is defaulted to STRING.

 @DiscriminatorValue(P)
 public class Person implements java.io.Serializable
 {
private int id;
private String name;
private Calendar birthdate;
private String origin;

@Id
@GeneratedValue
public int getId()
{
return id;
}

public void setId(int id)
{
this.id = id;
}

public String getName()
{
return name;
}

public void setName(String name)
{
this.name = name;
}

@Temporal(TemporalType.DATE)
public Calendar getBirthdate()
{
return birthdate;
}

 I think that's the issue - @Temporal. According to the spec - JSR 220:
 Enterprise JavaBeansTM,Version 3.0 Java Persistence API - page 234:

 xsd:simpleType name=temporal-type
 xsd:annotation
 xsd:documentation
 public enum TemporalType {
 DATE, // java.sql.Date
 TIME, // java.sql.Time
 TIMESTAMP // java.sql.Timestamp
 }
 /xsd:documentation
 /xsd:annotation
 xsd:restriction base=xsd:token
 xsd:enumeration value=DATE/
 xsd:enumeration value=TIME/
 xsd:enumeration value=TIMESTAMP/
 /xsd:restriction
 /xsd:simpleType

 so Calendar seems to not be accepted for @Temporal annotation. Change
 the return type of the getter.

 I think the Person entity is not mapped correctly and when you run
 your sample you are off the error messages which tell you the Person
 entity could not be mapped.

 Jacek

 --
 Jacek Laskowski
 Notatnik Projektanta Java EE - http://www.JacekLaskowski.pl



Re: error writing tuple to database the owning entity is not mapped geronimo 2.1.1

2008-07-06 Thread Mario Kofler

 If a person becomes a director, (s)he won't be able to
 resign and become a manager or just a developer?

that's right. for my application it is assumed that if a person is a
director this person is just a director and cannot be an actor in the
same time.


 On to your issue...

  so i want to write a Person first, to keep it simple. unfortunately i get an
  error when i try to perform a write:

 Could you show us how Person looks like? And your persistence.xml too.
 I assume you don't use orm.xml or alike, do you? If so, show it too.

so thanks, the persistence.xml we discussed a lot already if i
remember right ;):

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/persistence_1_0.xsd;
 version=1.0
  persistence-unit name=valhalla transaction-type=JTA
descriptionvideothek/description
providerorg.apache.openjpa.persistence.PersistenceProviderImpl/provider
classvt.bean.entity.Person/class
classvt.bean.entity.Actor/class
classvt.bean.entity.Director/class
classvt.bean.entity.Movie/class
classvt.bean.entity.Dvd/class

properties

  property name=openjpa.jdbc.DBDictionary value=postgres/
  !--property name=openjpa.LockManager value=pessimistic/--   
/properties
jta-data-sourcejdbc/postgres/jta-data-source
non-jta-data-sourcejdbc/postgres/non-jta-data-source
  /persistence-unit
/persistence



 the Person entity:


/*Persistent Entity Person*/
@Entity
@Table(name=person)
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name=role, discriminatorType=DiscriminatorType.STRING)
@DiscriminatorValue(P)
public class Person implements java.io.Serializable
{
private int id;
private String name;
private Calendar birthdate;
private String origin;

@Id
@GeneratedValue
public int getId()
{
return id;
}

public void setId(int id)
{
this.id = id;
}

public String getName()
{
return name;
}

public void setName(String name)
{
this.name = name;
}

@Temporal(TemporalType.DATE)
public Calendar getBirthdate()
{
return birthdate;
}

public void setBirthdate(Calendar birthdate)
{
this.birthdate = birthdate;
}

public String getOrigin()
{
return origin;
}

public void setOrigin(String origin)
{
this.origin = origin;
}

}


and yes i do not use an orm.xml

thanks a lot for helping,

greetings,

mario.


 Jacek

 --
 Jacek Laskowski
 Notatnik Projektanta Java EE - http://www.JacekLaskowski.pl


Re: error writing tuple to database the owning entity is not mapped geronimo 2.1.1

2008-07-06 Thread Jacek Laskowski
On Sun, Jul 6, 2008 at 11:34 AM, Mario Kofler [EMAIL PROTECTED] wrote:


Hi Mario,

Let's make it simpler by removing some unneeded, defaulted
configuration values in your sample.

 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/persistence_1_0.xsd;
 version=1.0
  persistence-unit name=valhalla transaction-type=JTA

Hint: you may remove transaction-type as it's JTA in managed
environment like Geronimo.

descriptionvideothek/description
providerorg.apache.openjpa.persistence.PersistenceProviderImpl/provider

Provider defaults to openjpa in Geronimo. You may remove it.

classvt.bean.entity.Person/class
classvt.bean.entity.Actor/class
classvt.bean.entity.Director/class
classvt.bean.entity.Movie/class
classvt.bean.entity.Dvd/class

Not needed in managed environment like Geronimo. It makes things run
faster - no need to look for annotated classes, but am not sure if we
don't do this even though the class elements are specified.

Also, you showed Person entity class, but what about the rest? Either
remove them and let's play with a single entity only and add more
later or show all of them as I think the issue might be in the others.

properties

  property name=openjpa.jdbc.DBDictionary value=postgres/
  !--property name=openjpa.LockManager value=pessimistic/--
/properties
jta-data-sourcejdbc/postgres/jta-data-source
non-jta-data-sourcejdbc/postgres/non-jta-data-source

I think *data-source should be before properties element. Geronimo
should really be more strict.

 @Entity
 @Table(name=person)
 @Inheritance(strategy=InheritanceType.JOINED)
 @DiscriminatorColumn(name=role, discriminatorType=DiscriminatorType.STRING)

discriminatorType is defaulted to STRING.

 @DiscriminatorValue(P)
 public class Person implements java.io.Serializable
 {
private int id;
private String name;
private Calendar birthdate;
private String origin;

@Id
@GeneratedValue
public int getId()
{
return id;
}

public void setId(int id)
{
this.id = id;
}

public String getName()
{
return name;
}

public void setName(String name)
{
this.name = name;
}

@Temporal(TemporalType.DATE)
public Calendar getBirthdate()
{
return birthdate;
}

I think that's the issue - @Temporal. According to the spec - JSR 220:
Enterprise JavaBeansTM,Version 3.0 Java Persistence API - page 234:

xsd:simpleType name=temporal-type
xsd:annotation
xsd:documentation
public enum TemporalType {
DATE, // java.sql.Date
TIME, // java.sql.Time
TIMESTAMP // java.sql.Timestamp
}
/xsd:documentation
/xsd:annotation
xsd:restriction base=xsd:token
xsd:enumeration value=DATE/
xsd:enumeration value=TIME/
xsd:enumeration value=TIMESTAMP/
/xsd:restriction
/xsd:simpleType

so Calendar seems to not be accepted for @Temporal annotation. Change
the return type of the getter.

I think the Person entity is not mapped correctly and when you run
your sample you are off the error messages which tell you the Person
entity could not be mapped.

Jacek

-- 
Jacek Laskowski
Notatnik Projektanta Java EE - http://www.JacekLaskowski.pl


error writing tuple to database the owning entity is not mapped geronimo 2.1.1

2008-07-05 Thread the666pack

hello,

i am back again and hope someone can help me out with my new error in
geronimo 2.1.1. 

my database scheme consists of a Person entity and a Director entity which
is inherited from the Person entity. 

so i want to write a Person first, to keep it simple. unfortunately i get an
error when i try to perform a write:

openjpa-1.0.2-r420667:627158 fatal user error
org.apache.openjpa.persistence.ArgumentException: Attempt to map
vt.bean.entity.Person.id failed: the owning entity is not mapped.

i was successfully writing tuples of my application to database with
geronimo version 2.0.2 and also did not change nothing in my .ear archive
and application. 

i found a jira on a similar topic:

https://issues.apache.org/jira/browse/OPENJPA-524

but i am not sure if this is the same problem, and the jira is in a
fixed-solved status.

the full debug view is:

  [exec] 10:51:04,196 INFO  [OpenEJB] invoking method create on
videothek.jar/WriteDataBean
 [exec] 10:51:04,268 INFO  [OpenEJB] finished invoking method create
 [exec] 10:51:04,300 INFO  [Transaction] TX Required: Started
transaction [EMAIL PROTECTED]
 [exec] 10:51:04,304 INFO  [Transaction] TX Required: Committing
transaction [EMAIL PROTECTED]
 [exec] 10:51:04,305 INFO  [Transaction] TX Required: Started
transaction [EMAIL PROTECTED]
 [exec] 10:51:04,314 INFO  [Runtime] Starting OpenJPA 1.0.2
 [exec] 10:51:04,427 INFO  [JDBC] Using dictionary class
org.apache.openjpa.jdbc.sql.PostgresDictionary.
 [exec] 10:51:05,734 INFO  [Transaction] TX Required: setRollbackOnly()
on transaction
[EMAIL PROTECTED]
 [exec] 10:51:05,735 INFO  [Transaction] TX Required: Rolling back
transaction [EMAIL PROTECTED]
 [exec] javax.ejb.EJBException: The bean encountered a non-application
exception.; nested exception is:
 [exec] openjpa-1.0.2-r420667:627158 fatal user error
org.apache.openjpa.persistence.ArgumentException: Attempt to map
vt.bean.entity.Person.id failed: the owning entity is not mapped.
 [exec] at
org.apache.openejb.core.ivm.BaseEjbProxyHandler.convertException(BaseEjbProxyHandler.java:366)
 [exec] at
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:251)
 [exec] at
org.apache.openejb.util.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
 [exec] at $Proxy23.writeToDB(Unknown Source)
 [exec] at vt.servlet.AddServlet.doGet(AddServlet.java:48)
 [exec] at
javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
 [exec] at
javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
 [exec] at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 [exec] at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 [exec] at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
 [exec] at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
 [exec] at
org.apache.geronimo.tomcat.valve.DefaultSubjectValve.invoke(DefaultSubjectValve.java:56)
 [exec] at
org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(GeronimoStandardContext.java:406)
 [exec] at
org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java:47)
 [exec] at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
 [exec] at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 [exec] at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 [exec] at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
 [exec] at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
 [exec] at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
 [exec] at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
 [exec] at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
 [exec] at java.lang.Thread.run(Thread.java:619)
 [exec] Caused by: openjpa-1.0.2-r420667:627158 fatal user error
org.apache.openjpa.persistence.ArgumentException: Attempt to map
vt.bean.entity.Person.id failed: the owning entity is not mapped.
 [exec] at
org.apache.openjpa.jdbc.meta.MappingInfo.assertTable(MappingInfo.java:544)
 [exec] at
org.apache.openjpa.jdbc.meta.MappingInfo.createColumns(MappingInfo.java:496)
 [exec] at
org.apache.openjpa.jdbc.meta.ValueMappingInfo.getColumns(ValueMappingInfo.java:143)
 [exec] at
org.apache.openjpa.jdbc.meta.strats.PrimitiveFieldStrategy.map(PrimitiveFieldStrategy.java:83)
 [exec] at
org.apache.openjpa.jdbc.meta.FieldMapping.setStrategy(FieldMapping.java:120)
 [exec] at

Re: error writing tuple to database the owning entity is not mapped geronimo 2.1.1

2008-07-05 Thread Jacek Laskowski
On Sat, Jul 5, 2008 at 11:19 AM, the666pack [EMAIL PROTECTED] wrote:

 my database scheme consists of a Person entity and a Director entity which
 is inherited from the Person entity.

Hi,

It won't solve your issue, but why is Person a superclass of
Directory. Shouldn't Director be a role of a Person in a given
scenario? If a person becomes a director, (s)he won't be able to
resign and become a manager or just a developer?

On to your issue...

 so i want to write a Person first, to keep it simple. unfortunately i get an
 error when i try to perform a write:

Could you show us how Person looks like? And your persistence.xml too.
I assume you don't use orm.xml or alike, do you? If so, show it too.

Jacek

-- 
Jacek Laskowski
Notatnik Projektanta Java EE - http://www.JacekLaskowski.pl