openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Dick (JIRA)" <j...@apache.org>
Subject [jira] Commented: (OPENJPA-729) @Column( insertable=false ) broken, causes 'can not be set' exception
Date Thu, 18 Sep 2008 22:54:44 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-729?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12632435#action_12632435
] 

Michael Dick commented on OPENJPA-729:
--------------------------------------

Hi Gil,

OPENJPA-665 deals with the nullable attribute of a Column annotation so I'm assuming you have
that set to false as well. Maybe your entity field looks something like this:  

    @Column(name="NONIN", insertable=false, nullable=false)
    private String nonInsertable;
    

If you've specified insertable=false and nullable=false there's really no way to add a new
entity. If a field is annotated with insertable=false the JPA provider will ignore it when
issuing INSERT statements. If nullable=false adds a non null constraint in the database (assuming
you're generating the tables). The combination prevents em.persist(myEntity) from working.


The combination could be useful if the application only operates on a fully populated database
(or you want new rows to be inserted elsewhere). 

With updateable=false and nullable=false you have the opposite scenario. You can set a value
when you insert the entity (and must do so), and the value can never be changed. 

I tested this scenario with a nightly build (1.3.0-SNAPSHOT) and it looks like it's working
correctly. 

I also tried just setting @Column(insertable=false) and didn't run into any UserExceptions
(on 1.2.0, 1.2.1-SNAPSHOT, and 1.3.0). Are there any other annotations on your persistent
properties that could be causing other problems? 

If you have a testcase or a sample entity that reproduces the problem could you post it here?


> @Column( insertable=false ) broken, causes 'can not be set' exception
> ---------------------------------------------------------------------
>
>                 Key: OPENJPA-729
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-729
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 1.2.0
>            Reporter: Gil Markham
>
> It appears the patch to fix OPENJPA-665 has caused UserExceptions to always occur on
insert if using 'insertable=false' on a @Column annotation. I haven't verified by I would
assume the same holds true for updates and 'updatable=false' considering the code looks the
same.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message