Skip to main content

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

  • From: michael keith <michael.keith@...>
  • To: jsr338-experts@...
  • Cc: Nicolas Seyvet <nicolas.seyvet@...>
  • Subject: [jpa-spec users] [jsr338-experts] Re: insertable = false, updatable = false & field re-use
  • Date: Tue, 22 Jan 2013 10:00:24 -0500
  • List-id: <jsr338-experts.jpa-spec.java.net>
  • Organization: Oracle Corporation

Ideally we would have some kind of annotation that just pointed to the other attribute to signify that the column was defined by it and that only one of the mappings should write to the column or contribute to schema gen (a bit like the @MapsId situation, but in the opposite direction). Since in practice something already works, though, and there's not really any time left to add new features to the spec in jsr 338 it won't likely happen in this round. Maybe in the future if enough people ask for it?

On 22/01/2013 8:50 AM, Nicolas Seyvet wrote:
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@...]
Sent: Tuesday, January 22, 2013 2:24 PM
To: jsr338-experts@...
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@...]
Sent: Monday, January 21, 2013 2:29 PM
To: jsr338-experts@...
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


[jpa-spec users] [jsr338-experts] insertable = false, updatable = false & field re-use

Nicolas Seyvet 01/14/2013

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

Linda DeMichiel 01/17/2013

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

Nicolas Seyvet 01/21/2013

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

michael keith 01/21/2013

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

Nicolas Seyvet 01/22/2013

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

michael keith 01/22/2013

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

Nicolas Seyvet 01/22/2013

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

michael keith 01/22/2013

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

Linda DeMichiel 01/22/2013
 
 
Close
loading
Please Confirm
Close