Can we interpret No Answer on this one from anybody as a Not Support /
Not Interested / Go away? ;-)
If this cannot be supported (?), would it fair to suggest at least
decent error handling for null values in @Id attributes?
Are any clarifications needed (c.f. initially attached unit test) ?
Thanks.
-----Original Message-----
From: Michael Vorburger [
mailto:mvorburger@xxxxxxxxxxxxxxxxx]
Sent: Wednesday, November 11, 2009 6:57 PM
To: users@xxxxxxxxxxxxxxxxxx
Subject: NULL in @Id columns leads to "disappearing" objects
Hello again!
We are working with an existing ('legacy') DB schema where columns which
are part of a "logical" (there is no physical PRIMARY KEY CONSTRAINT)
composed primary key (mapped in JPA via an @IdClass) CAN BE NULL.
Neither the JPA Spec nor any OpenJPA documentation says that this is not
permitted or requires that all @Id field never be null...
... but OpenJPA "looses" such objects when mapping in ResultSets - i.e.
you get Query result Lists containing null elements! Attached is a
small test case project, hopefully illustring this well (if the ZIP
makes it through the list?).
Any ideas how to "work-around" this on the (Open)JPA side (assume I
can't do much about the 10 year old legacy schema installed 120 client
sites :) ? Can you think of any other mapping approaches than a
straightforward @IdClass as shown in the attached example? Otherwise...
do you confirm / agree that this is a bug? Easy to fix?? ;)
Regards & lot's of thanks for feedbacks, Michael Vorburger
____________________________________________________________
* This email and any files transmitted with it are CONFIDENTIAL and
intended
solely for the use of the individual or entity to which they are
addressed.
* Any unauthorized copying, disclosure, or distribution of the material
within
this email is strictly forbidden.
* Any views or opinions presented within this e-mail are solely those of
the
author and do not necessarily represent those of Odyssey Financial
Technologies SA unless otherwise specifically stated.
* An electronic message is not binding on its sender. Any message
referring to
a binding engagement must be confirmed in writing and duly signed.
* If you have received this email in error, please notify the sender
immediately
and delete the original.
____________________________________________________________
? This email and any files transmitted with it are CONFIDENTIAL and intended
solely for the use of the individual or entity to which they are addressed.
? Any unauthorized copying, disclosure, or distribution of the material within
this email is strictly forbidden.
? Any views or opinions presented within this e-mail are solely those of the
author and do not necessarily represent those of Odyssey Financial
Technologies SA unless otherwise specifically stated.
? An electronic message is not binding on its sender. Any message referring to
a binding engagement must be confirmed in writing and duly signed.
? If you have received this email in error, please notify the sender immediately
and delete the original.
Thread at a glance:
Previous Message by Date:
click to view message preview
Re: @Version annotation
Hi,
I removed the @GeneratedValue
but still no changement.
when updating i don't see any version number.
Is my configuration correct or do I have to put some configurations in the
persistence file.
Greets K,
Craig L Russell wrote:
>
> Seems like it would be useful for OpenJPA to issue a warning or an
> error in the case of the user specifying both @Version and
> @GeneratedValue on the same property.
>
> Craig
>
> On Nov 16, 2009, at 9:08 AM, Fay Wang wrote:
>
>> Hi,
>> You don't need to put generatedValue annotation for the version
>> field. Openjpa will keep track of the version for you.
>>
>> @Version
>> public long getVersion() {
>> return this.version;
>> }
>>
>>
>>
>> ----- Original Message ----
>> From: yokenji <kenji2904@xxxxxxxxx>
>> To: users@xxxxxxxxxxxxxxxxxx
>> Sent: Mon, November 16, 2009 8:46:48 AM
>> Subject: @Version annotation
>>
>>
>> Hi there,
>>
>> I trying to use an annotatoin field @version but when updating the
>> record i
>> don't see any version in the database.
>>
>> Also,
>> Element class:
>>
>> package entities;
>>
>> import java.io.Serializable;
>> import java.util.Set;
>>
>> import javax.annotation.Generated;
>> import javax.persistence.CascadeType;
>> import javax.persistence.Column;
>> import javax.persistence.Entity;
>> import javax.persistence.FetchType;
>> import javax.persistence.GeneratedValue;
>> import javax.persistence.GenerationType;
>> import javax.persistence.Id;
>> import javax.persistence.JoinColumn;
>> import javax.persistence.ManyToOne;
>> import javax.persistence.NamedQueries;
>> import javax.persistence.NamedQuery;
>> import javax.persistence.OneToMany;
>> import javax.persistence.Table;
>> import javax.persistence.Temporal;
>> import javax.persistence.TemporalType;
>> import javax.persistence.Version;
>>
>> import org.apache.openjpa.persistence.jdbc.ForeignKey;
>>
>> /**
>> * @author Ken
>> */
>> @Entity
>> @NamedQueries({
>> @NamedQuery(name="roots.Element",
>> query="Select e From Element e" +
>> " where e.parentElement is null"),
>> @NamedQuery(name="one.Element",
>> query="Select e From Element e" +
>> " where e.dbID = :id")
>> })
>> @Table(name="Element")
>> public class Element implements ElementInterface, Serializable {
>>
>> private static final long serialVersionUID = 4627343050926103812L;
>>
>> private String dbID;
>> private String internID;
>> private String name;
>> private String description;
>> private long version;
>>
>> private Set<Property> properties;
>> private Element parentElement;
>> private Set<Element> childElements;
>>
>> /**
>> * This is the default constructor.
>> */
>> public Element() {
>> }
>>
>> /**
>> * @see entities.ElementInterface#setDbID(java.lang.String)
>> */
>> public void setDbID(String dbID) {
>> this.dbID = dbID;
>> }
>>
>> /**
>> * @see entities.ElementInterface#getDbID()
>> */
>> @Id
>> @GeneratedValue(strategy = GenerationType.AUTO, generator="uuid-hex")
>> public String getDbID() {
>> return this.dbID;
>> }
>>
>> /**
>> * @see entities.ElementInterface#setInternID(java.lang.String)
>> */
>> public void setInternID(String internID) {
>> this.internID = internID;
>> }
>>
>> /**
>> * @see entities.ElementInterface#getInternID()
>> */
>> public String getInternID() {
>> return this.internID;
>> }
>>
>>
>> /**
>> * @see entities.ElementInterface#getName()
>> */
>> public String getName() {
>> return this.name;
>> }
>>
>> /**
>> * @see entities.ElementInterface#setName(java.lang.String)
>> */
>> public void setName(String name) {
>> this.name = name;
>> }
>>
>> /**
>> * @see entities.ElementInterface#setDescription(java.lang.String)
>> */
>> public void setDescription(String description) {
>> this.description = description;
>> }
>>
>> /**
>> * @see entities.ElementInterface#getDescription()
>> */
>> public String getDescription() {
>> return this.description;
>> }
>>
>> /**
>> * @see entities.ElementInterface#setVersion(java.util.Date)
>> */
>> private void setVersion(int version) {
>> this.version = version;
>> }
>>
>> /**
>> * @see entities.ElementInterface#getVersion()
>> */
>> @Version
>> @GeneratedValue(strategy=GenerationType.AUTO)
>> public long getVersion() {
>> return this.version;
>> }
>>
>> /**
>> * Set the element properties.
>> *
>> * @param Set<Property> properties
>> */
>> public void setProperties(Set<Property> properties) {
>> this.properties = properties;
>> }
>>
>> /**
>> * Get the element properties.
>> *
>> * @return Set<Property>
>> */
>> @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER,
>> mappedBy="element")
>> public Set<Property> getProperties() {
>> return properties;
>> }
>>
>> /**
>> * Set the element parent.
>> *
>> * @param Element parentElement
>> */
>> public void setParentElement(Element parentElement) {
>> this.parentElement = parentElement;
>> }
>>
>> /**
>> * Get the element parent.
>> *
>> * @return Element
>> */
>> @ManyToOne(optional=true, fetch=FetchType.LAZY)
>> @ForeignKey(name="FK_parent_element")
>> @JoinColumn(name="parent_element", referencedColumnName="dbID")
>> public Element getParentElement() {
>> return parentElement;
>> }
>>
>> /**
>> * Set the element children.
>> *
>> * @param Set<Element> childElements
>> */
>> public void setChildElements(Set<Element> childElements) {
>> this.childElements = childElements;
>> }
>>
>> /**
>> * Get the element children.
>> *
>> * @return Set<Element>
>> */
>> @OneToMany(cascade=CascadeType.ALL, mappedBy="parentElement",
>> fetch=FetchType.EAGER)
>> public Set<Element> getChildElements() {
>> return childElements;
>> }
>>
>> }
>>
>> Class Property:
>>
>>
>> package entities;
>>
>> import java.io.Serializable;
>> import javax.persistence.*;
>> import org.apache.openjpa.persistence.jdbc.ForeignKey;
>>
>> /**
>> * @author Ken
>> */
>> @Entity
>> @NamedQueries({
>> @NamedQuery(name="all.properties",
>> query="Select p From Property p"),
>> @NamedQuery(name="elementTemplate.properties",
>> query="Select p From Property p" +
>> " where p.elementTemplate = :owner"),
>> @NamedQuery(name="one.property",
>> query="Select p From Property p" +
>> " where p.dbID = :id")
>> })
>> @Table(name="Property")
>> public class Property implements Serializable {
>>
>> private static final long serialVersionUID = -6988886476498387460L;
>>
>> private String dbID;
>> private String property;
>> private String value;
>> private Element element;
>> private ElementTemplate elementTemplate;
>>
>> /**
>> * This is the default constructor.
>> */
>> public Property() {
>> }
>>
>> /**
>> * Set the property dbID.
>> *
>> * @param String dbID
>> */
>> public void setDbID(String dbID) {
>> this.dbID = dbID;
>> }
>>
>> /**
>> * Get the property dbID.
>> *
>> * @return
>> */
>> @Id
>> @GeneratedValue(strategy=GenerationType.AUTO, generator="uuid-hex")
>> public String getDbID() {
>> return this.dbID;
>> }
>>
>> /**
>> * Set the property property
>> *
>> * @param String property
>> */
>> public void setProperty(String property) {
>> this.property = property;
>> }
>>
>> /**
>> * Get the property property.
>> *
>> * @return String
>> */
>> public String getProperty() {
>> return property;
>> }
>>
>> /**
>> * Set the property value.
>> *
>> * @param String value
>> */
>> public void setValue(String value) {
>> this.value = value;
>> }
>>
>> /**
>> * Get the property value.
>> *
>> * @return String
>> */
>> public String getValue() {
>> return value;
>> }
>>
>> /**
>> * Set property element.
>> *
>> * @param Element element
>> */
>> public void setElement(Element element) {
>> this.element = element;
>> }
>>
>> /**
>> * Get the property element.
>> *
>> * @return Element
>> */
>> @ManyToOne(fetch=FetchType.LAZY)
>> @ForeignKey(name="FK_property_element")
>> @JoinColumn(name="element")
>> public Element getElement() {
>> return element;
>> }
>>
>> /**
>> * Set the property elementTemplate.
>> *
>> * @param ElementTemplate elementTemplate
>> */
>> public void setElementTemplate(ElementTemplate elementTemplate) {
>> this.elementTemplate = elementTemplate;
>> }
>>
>> /**
>> * Get the property elementTemplate.
>> *
>> * @return ElementTemplate
>> */
>> @ManyToOne(fetch=FetchType.LAZY)
>> @ForeignKey(name="FK_property_elementTemplate")
>> @JoinColumn(name="elementTemplate")
>> public ElementTemplate getElementTemplate() {
>> return elementTemplate;
>> }
>>
>> }
>>
>> to update the element I do this:
>> Element element = em.find(Element.class, elementID);
>>
>> //Add changements to the element
>>
>>
>> // update the element.
>> em.persist(element);
>>
>> The update worked but I don't see any version number in my database
>> field.
>>
>> Please help :)
>>
>>
>> --
>> View this message in context:
>> http://n2.nabble.com/Version-annotation-tp4013067p4013067.html
>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>>
>>
>>
>>
>
> Craig L Russell
> Architect, Sun Java Enterprise System http://db.apache.org/jdo
> 408 276-5638 mailto:Craig.Russell@xxxxxxx
> P.S. A good JDO? O, Gasp!
>
>
>
>
--
View this message in context:
http://n2.nabble.com/Version-annotation-tp4013067p4017236.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Next Message by Date:
click to view message preview
Re: @Version annotation
Problem is fixed thx for all. :)
yokenji wrote:
>
> Hi,
>
> I removed the @GeneratedValue
> but still no changement.
> when updating i don't see any version number.
> Is my configuration correct or do I have to put some configurations in the
> persistence file.
>
> Greets K,
>
>
> Craig L Russell wrote:
>>
>> Seems like it would be useful for OpenJPA to issue a warning or an
>> error in the case of the user specifying both @Version and
>> @GeneratedValue on the same property.
>>
>> Craig
>>
>> On Nov 16, 2009, at 9:08 AM, Fay Wang wrote:
>>
>>> Hi,
>>> You don't need to put generatedValue annotation for the version
>>> field. Openjpa will keep track of the version for you.
>>>
>>> @Version
>>> public long getVersion() {
>>> return this.version;
>>> }
>>>
>>>
>>>
>>> ----- Original Message ----
>>> From: yokenji <kenji2904@xxxxxxxxx>
>>> To: users@xxxxxxxxxxxxxxxxxx
>>> Sent: Mon, November 16, 2009 8:46:48 AM
>>> Subject: @Version annotation
>>>
>>>
>>> Hi there,
>>>
>>> I trying to use an annotatoin field @version but when updating the
>>> record i
>>> don't see any version in the database.
>>>
>>> Also,
>>> Element class:
>>>
>>> package entities;
>>>
>>> import java.io.Serializable;
>>> import java.util.Set;
>>>
>>> import javax.annotation.Generated;
>>> import javax.persistence.CascadeType;
>>> import javax.persistence.Column;
>>> import javax.persistence.Entity;
>>> import javax.persistence.FetchType;
>>> import javax.persistence.GeneratedValue;
>>> import javax.persistence.GenerationType;
>>> import javax.persistence.Id;
>>> import javax.persistence.JoinColumn;
>>> import javax.persistence.ManyToOne;
>>> import javax.persistence.NamedQueries;
>>> import javax.persistence.NamedQuery;
>>> import javax.persistence.OneToMany;
>>> import javax.persistence.Table;
>>> import javax.persistence.Temporal;
>>> import javax.persistence.TemporalType;
>>> import javax.persistence.Version;
>>>
>>> import org.apache.openjpa.persistence.jdbc.ForeignKey;
>>>
>>> /**
>>> * @author Ken
>>> */
>>> @Entity
>>> @NamedQueries({
>>> @NamedQuery(name="roots.Element",
>>> query="Select e From Element e" +
>>> " where e.parentElement is null"),
>>> @NamedQuery(name="one.Element",
>>> query="Select e From Element e" +
>>> " where e.dbID = :id")
>>> })
>>> @Table(name="Element")
>>> public class Element implements ElementInterface, Serializable {
>>>
>>> private static final long serialVersionUID = 4627343050926103812L;
>>>
>>> private String dbID;
>>> private String internID;
>>> private String name;
>>> private String description;
>>> private long version;
>>>
>>> private Set<Property> properties;
>>> private Element parentElement;
>>> private Set<Element> childElements;
>>>
>>> /**
>>> * This is the default constructor.
>>> */
>>> public Element() {
>>> }
>>>
>>> /**
>>> * @see entities.ElementInterface#setDbID(java.lang.String)
>>> */
>>> public void setDbID(String dbID) {
>>> this.dbID = dbID;
>>> }
>>>
>>> /**
>>> * @see entities.ElementInterface#getDbID()
>>> */
>>> @Id
>>> @GeneratedValue(strategy = GenerationType.AUTO, generator="uuid-hex")
>>> public String getDbID() {
>>> return this.dbID;
>>> }
>>>
>>> /**
>>> * @see entities.ElementInterface#setInternID(java.lang.String)
>>> */
>>> public void setInternID(String internID) {
>>> this.internID = internID;
>>> }
>>>
>>> /**
>>> * @see entities.ElementInterface#getInternID()
>>> */
>>> public String getInternID() {
>>> return this.internID;
>>> }
>>>
>>>
>>> /**
>>> * @see entities.ElementInterface#getName()
>>> */
>>> public String getName() {
>>> return this.name;
>>> }
>>>
>>> /**
>>> * @see entities.ElementInterface#setName(java.lang.String)
>>> */
>>> public void setName(String name) {
>>> this.name = name;
>>> }
>>>
>>> /**
>>> * @see entities.ElementInterface#setDescription(java.lang.String)
>>> */
>>> public void setDescription(String description) {
>>> this.description = description;
>>> }
>>>
>>> /**
>>> * @see entities.ElementInterface#getDescription()
>>> */
>>> public String getDescription() {
>>> return this.description;
>>> }
>>>
>>> /**
>>> * @see entities.ElementInterface#setVersion(java.util.Date)
>>> */
>>> private void setVersion(int version) {
>>> this.version = version;
>>> }
>>>
>>> /**
>>> * @see entities.ElementInterface#getVersion()
>>> */
>>> @Version
>>> @GeneratedValue(strategy=GenerationType.AUTO)
>>> public long getVersion() {
>>> return this.version;
>>> }
>>>
>>> /**
>>> * Set the element properties.
>>> *
>>> * @param Set<Property> properties
>>> */
>>> public void setProperties(Set<Property> properties) {
>>> this.properties = properties;
>>> }
>>>
>>> /**
>>> * Get the element properties.
>>> *
>>> * @return Set<Property>
>>> */
>>> @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER,
>>> mappedBy="element")
>>> public Set<Property> getProperties() {
>>> return properties;
>>> }
>>>
>>> /**
>>> * Set the element parent.
>>> *
>>> * @param Element parentElement
>>> */
>>> public void setParentElement(Element parentElement) {
>>> this.parentElement = parentElement;
>>> }
>>>
>>> /**
>>> * Get the element parent.
>>> *
>>> * @return Element
>>> */
>>> @ManyToOne(optional=true, fetch=FetchType.LAZY)
>>> @ForeignKey(name="FK_parent_element")
>>> @JoinColumn(name="parent_element", referencedColumnName="dbID")
>>> public Element getParentElement() {
>>> return parentElement;
>>> }
>>>
>>> /**
>>> * Set the element children.
>>> *
>>> * @param Set<Element> childElements
>>> */
>>> public void setChildElements(Set<Element> childElements) {
>>> this.childElements = childElements;
>>> }
>>>
>>> /**
>>> * Get the element children.
>>> *
>>> * @return Set<Element>
>>> */
>>> @OneToMany(cascade=CascadeType.ALL, mappedBy="parentElement",
>>> fetch=FetchType.EAGER)
>>> public Set<Element> getChildElements() {
>>> return childElements;
>>> }
>>>
>>> }
>>>
>>> Class Property:
>>>
>>>
>>> package entities;
>>>
>>> import java.io.Serializable;
>>> import javax.persistence.*;
>>> import org.apache.openjpa.persistence.jdbc.ForeignKey;
>>>
>>> /**
>>> * @author Ken
>>> */
>>> @Entity
>>> @NamedQueries({
>>> @NamedQuery(name="all.properties",
>>> query="Select p From Property p"),
>>> @NamedQuery(name="elementTemplate.properties",
>>> query="Select p From Property p" +
>>> " where p.elementTemplate = :owner"),
>>> @NamedQuery(name="one.property",
>>> query="Select p From Property p" +
>>> " where p.dbID = :id")
>>> })
>>> @Table(name="Property")
>>> public class Property implements Serializable {
>>>
>>> private static final long serialVersionUID = -6988886476498387460L;
>>>
>>> private String dbID;
>>> private String property;
>>> private String value;
>>> private Element element;
>>> private ElementTemplate elementTemplate;
>>>
>>> /**
>>> * This is the default constructor.
>>> */
>>> public Property() {
>>> }
>>>
>>> /**
>>> * Set the property dbID.
>>> *
>>> * @param String dbID
>>> */
>>> public void setDbID(String dbID) {
>>> this.dbID = dbID;
>>> }
>>>
>>> /**
>>> * Get the property dbID.
>>> *
>>> * @return
>>> */
>>> @Id
>>> @GeneratedValue(strategy=GenerationType.AUTO, generator="uuid-hex")
>>> public String getDbID() {
>>> return this.dbID;
>>> }
>>>
>>> /**
>>> * Set the property property
>>> *
>>> * @param String property
>>> */
>>> public void setProperty(String property) {
>>> this.property = property;
>>> }
>>>
>>> /**
>>> * Get the property property.
>>> *
>>> * @return String
>>> */
>>> public String getProperty() {
>>> return property;
>>> }
>>>
>>> /**
>>> * Set the property value.
>>> *
>>> * @param String value
>>> */
>>> public void setValue(String value) {
>>> this.value = value;
>>> }
>>>
>>> /**
>>> * Get the property value.
>>> *
>>> * @return String
>>> */
>>> public String getValue() {
>>> return value;
>>> }
>>>
>>> /**
>>> * Set property element.
>>> *
>>> * @param Element element
>>> */
>>> public void setElement(Element element) {
>>> this.element = element;
>>> }
>>>
>>> /**
>>> * Get the property element.
>>> *
>>> * @return Element
>>> */
>>> @ManyToOne(fetch=FetchType.LAZY)
>>> @ForeignKey(name="FK_property_element")
>>> @JoinColumn(name="element")
>>> public Element getElement() {
>>> return element;
>>> }
>>>
>>> /**
>>> * Set the property elementTemplate.
>>> *
>>> * @param ElementTemplate elementTemplate
>>> */
>>> public void setElementTemplate(ElementTemplate elementTemplate) {
>>> this.elementTemplate = elementTemplate;
>>> }
>>>
>>> /**
>>> * Get the property elementTemplate.
>>> *
>>> * @return ElementTemplate
>>> */
>>> @ManyToOne(fetch=FetchType.LAZY)
>>> @ForeignKey(name="FK_property_elementTemplate")
>>> @JoinColumn(name="elementTemplate")
>>> public ElementTemplate getElementTemplate() {
>>> return elementTemplate;
>>> }
>>>
>>> }
>>>
>>> to update the element I do this:
>>> Element element = em.find(Element.class, elementID);
>>>
>>> //Add changements to the element
>>>
>>>
>>> // update the element.
>>> em.persist(element);
>>>
>>> The update worked but I don't see any version number in my database
>>> field.
>>>
>>> Please help :)
>>>
>>>
>>> --
>>> View this message in context:
>>> http://n2.nabble.com/Version-annotation-tp4013067p4013067.html
>>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>>>
>>>
>>>
>>>
>>
>> Craig L Russell
>> Architect, Sun Java Enterprise System http://db.apache.org/jdo
>> 408 276-5638 mailto:Craig.Russell@xxxxxxx
>> P.S. A good JDO? O, Gasp!
>>
>>
>>
>>
>
>
--
View this message in context:
http://n2.nabble.com/Version-annotation-tp4013067p4017289.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Previous Message by Thread:
click to view message preview
NULL in @Id columns leads to "disappearing" objects
Hello again!
We are working with an existing ('legacy') DB schema where columns which
are part of a "logical" (there is no physical PRIMARY KEY CONSTRAINT)
composed primary key (mapped in JPA via an @IdClass) CAN BE NULL.
Neither the JPA Spec nor any OpenJPA documentation says that this is not
permitted or requires that all @Id field never be null...
... but OpenJPA "looses" such objects when mapping in ResultSets - i.e.
you get Query result Lists containing null elements! Attached is a
small test case project, hopefully illustring this well (if the ZIP
makes it through the list?).
Any ideas how to "work-around" this on the (Open)JPA side (assume I
can't do much about the 10 year old legacy schema installed 120 client
sites :) ? Can you think of any other mapping approaches than a
straightforward @IdClass as shown in the attached example? Otherwise...
do you confirm / agree that this is a bug? Easy to fix?? ;)
Regards & lot's of thanks for feedbacks,
Michael Vorburger
____________________________________________________________
? This email and any files transmitted with it are CONFIDENTIAL and intended
solely for the use of the individual or entity to which they are addressed.
? Any unauthorized copying, disclosure, or distribution of the material within
this email is strictly forbidden.
? Any views or opinions presented within this e-mail are solely those of the
author and do not necessarily represent those of Odyssey Financial
Technologies SA unless otherwise specifically stated.
? An electronic message is not binding on its sender. Any message referring to
a binding engagement must be confirmed in writing and duly signed.
? If you have received this email in error, please notify the sender immediately
and delete the original.
openJPA_NullId.zip
Description: openJPA_NullId.zip
Next Message by Thread:
click to view message preview
Re: NULL in @Id columns leads to "disappearing" objects
Hi Michael,
On Tue, Nov 17, 2009 at 2:45 AM, Michael Vorburger <
mvorburger@xxxxxxxxxxxxxxxxx> wrote:
>
> Can we interpret No Answer on this one from anybody as a Not Support /
> Not Interested / Go away? ;-)
>
Interested, but in the middle of other things - will take a closer look when
the day job permits me (sound fair)?
> If this cannot be supported (?), would it fair to suggest at least
> decent error handling for null values in @Id attributes?
>
Agree. At first glance I think we can support this, but haven't looked at it
enough to really understand the problem.
> Are any clarifications needed (c.f. initially attached unit test) ?
>
The unit test was very helpful. In my initial read I thought you meant a
completely null ID, testcase set me straight there. No easy answer for you
though..
-mike
> Thanks.
>
>
> -----Original Message-----
> From: Michael Vorburger [mailto:mvorburger@xxxxxxxxxxxxxxxxx]
> Sent: Wednesday, November 11, 2009 6:57 PM
> To: users@xxxxxxxxxxxxxxxxxx
> Subject: NULL in @Id columns leads to "disappearing" objects
>
> Hello again!
>
> We are working with an existing ('legacy') DB schema where columns which
> are part of a "logical" (there is no physical PRIMARY KEY CONSTRAINT)
> composed primary key (mapped in JPA via an @IdClass) CAN BE NULL.
> Neither the JPA Spec nor any OpenJPA documentation says that this is not
> permitted or requires that all @Id field never be null...
>
> ... but OpenJPA "looses" such objects when mapping in ResultSets - i.e.
> you get Query result Lists containing null elements! Attached is a
> small test case project, hopefully illustring this well (if the ZIP
> makes it through the list?).
>
> Any ideas how to "work-around" this on the (Open)JPA side (assume I
> can't do much about the 10 year old legacy schema installed 120 client
> sites :) ? Can you think of any other mapping approaches than a
> straightforward @IdClass as shown in the attached example? Otherwise...
> do you confirm / agree that this is a bug? Easy to fix?? ;)
>
> Regards & lot's of thanks for feedbacks, Michael Vorburger
>
> ____________________________________________________________
>
> * This email and any files transmitted with it are CONFIDENTIAL and
> intended
> solely for the use of the individual or entity to which they are
> addressed.
> * Any unauthorized copying, disclosure, or distribution of the material
> within
> this email is strictly forbidden.
> * Any views or opinions presented within this e-mail are solely those of
> the
> author and do not necessarily represent those of Odyssey Financial
> Technologies SA unless otherwise specifically stated.
> * An electronic message is not binding on its sender. Any message
> referring to
> a binding engagement must be confirmed in writing and duly signed.
> * If you have received this email in error, please notify the sender
> immediately
> and delete the original.
>
> ____________________________________________________________
>
> • This email and any files transmitted with it are CONFIDENTIAL and
> intended
> solely for the use of the individual or entity to which they are
> addressed.
> • Any unauthorized copying, disclosure, or distribution of the material
> within
> this email is strictly forbidden.
> • Any views or opinions presented within this e-mail are solely those of
> the
> author and do not necessarily represent those of Odyssey Financial
> Technologies SA unless otherwise specifically stated.
> • An electronic message is not binding on its sender. Any message referring
> to
> a binding engagement must be confirmed in writing and duly signed.
> • If you have received this email in error, please notify the sender
> immediately
> and delete the original.
>