jsr338-experts@jpa-spec.java.net

[jsr338-experts] Re: insertable = false, updatable = false & field re-use

From: Nicolas Seyvet <nicolas.seyvet_at_ericsson.com>
Date: Tue, 22 Jan 2013 13:50:32 +0000

I mean to say that it was not the intent of the spec to detail this. Let me try to ask this question differently: Would it be good to standardize how the vendors support this as part of jsr-338 scope?

/Nicolas

-----Original Message-----
From: michael keith [mailto:michael.keith_at_oracle.com]
Sent: Tuesday, January 22, 2013 2:24 PM
To: jsr338-experts_at_jpa-spec.java.net
Cc: Nicolas Seyvet
Subject: Re: [jsr338-experts] Re: insertable = false, updatable = false & field re-use

No, I never said the spec "will not clarify the re-use of a table column". I just filled in some of the history and how we got to the current state. There is nothing in the spec that disallows reusing a column in this way, and this is how the vendors support it, so you shouldn't encounter any problems in your application.

-Mike

On 22/01/2013 7:06 AM, Nicolas Seyvet wrote:
> " and is what most vendors support since it at least uses standard options instead of a vendor-specific read-only annotation."
> Ok, but this is still not a specification.
>
> I guess the point is that this specification will not clarify the re-use of a table column within the same entity. Is that correct?
>
> /Nicolas
>
> -----Original Message-----
> From: michael keith [mailto:michael.keith_at_oracle.com]
> Sent: Monday, January 21, 2013 2:29 PM
> To: jsr338-experts_at_jpa-spec.java.net
> Cc: Linda DeMichiel
> Subject: [jsr338-experts] Re: insertable = false, updatable = false&
> field re-use
>
> In JPA 1.0 we did not get around to specifying a read-only mapping (in fact we still haven't).
> Because of that, using the insertable=false, updatable=false combination in the @Column mapping became the de facto way of setting a mapping to be read-only. It is not ideal since it requires setting multiple physical column/join column attributes when a logical read-only option would be the more appropriate option, but for the most part it has stuck and is what most vendors support since it at least uses standard options instead of a vendor-specific read-only annotation.
>
> -Mike
>
> On 17/01/2013 3:21 PM, Linda DeMichiel wrote:
>> Hi Nicolas,
>>
>> On 1/14/2013 12:01 AM, Nicolas Seyvet wrote:
>>> Hi,
>>>
>>> After using Hibernate for a while, I had assumed that insertable =
>>> false and updatable = false where useful for supporting reuse of
>>> columns across fields. But I got into an argument this week end
>>> with someone saying that the JPA spec does not define how/if this is
>>> mandated.
>>>
>>> Example:
>>> @Entity
>>> public class Company {
>>>
>>> @Id
>>> @GeneratedValue(strategy = GenerationType.IDENTITY)
>>> private Long id = null;
>>> private String name = null;
>>>
>>> @OneToMany(cascade = CascadeType.ALL, mappedBy = "company")
>>> private Set<Employee> employees = new HashSet<Employee>();
>>>
>>> [..]
>>> }
>>>
>>> @Entity
>>> public class Employee {
>>>
>>> @Id
>>> @GeneratedValue(strategy = GenerationType.IDENTITY)
>>> private Long id = null;
>>> private String name = null;
>>>
>>> @ManyToOne()
>>> @JoinColumn(name = "COMPANY_ID")
>>> private Company company = null;
>>>
>>> // Reuse of the field for the FK id
>>> @Column(name = "COMPANY_ID", insertable = false, updatable = false)
>>> private Long companyId;
>>>
>>> }
>>>
>>> I went through the JPA 2.1 draft, can could not find anything
>>> specific to this topic.
>>>
>>> Should this be clarified? Or was it discussed before I joined?
>>>
>> This was discussed back in the JPA 1.0 days. The semantics of
>> insertable / updatable are defined in the Column annotation and are
>> consistent with your use of them in the example above.
>>
>> -Linda
>>
>>
>>> Best regards,
>>> Nicolas Seyvet