----- Original Message -----
From: "Antonio Mailing" <antonio.mailing@xxxxxxxxx>
To: "Eclipselink-Users" <eclipselink-users@xxxxxxxxxxx>
Sent: Saturday, July 11, 2009 6:01:51 AM GMT -05:00 US/Canada Eastern
Subject: [eclipselink-users] updatable=false ignored
Hi,
I'm using EclipseLink 2.0M4 with Derby 10.5.1.1 and it looks like updatable=false is ignored. I have the following Entity with a title attribute set to updatable=false :
@Entity
public class BookCustomized {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "book_title", nullable = false, updatable = false)
private String title;
private Float price;
private String description;
private String isbn;
@Column(name = "nb_of_page", nullable = false)
private Integer nbOfPage;
private Boolean illustrations;
...
}
But I can update the attribute. Here is the test case. Any idea ?
Thanks
Antonio
@Test
public void titleShouldNotBeUpdatable() throws Exception {
BookCustomized book = new BookCustomized("The Hitchhiker's Guide to the Galaxy", 12.5F, "The Hitchhiker's Guide to the Galaxy is a science fiction comedy series created by Douglas Adams.", "1-84023-742-2", 354, false);
tx.begin();
em.persist(book);
tx.commit();
assertNotNull("ID should not be null", book.getId());
assertEquals("Title should be The Hitchhiker's Guide to the Galaxy", "The Hitchhiker's Guide to the Galaxy", book.getTitle());
tx.begin();
book = em.find(BookCustomized.class, book.getId());
assertEquals("Title should be The Hitchhiker's Guide to the Galaxy", "The Hitchhiker's Guide to the Galaxy", book.getTitle());
book.setTitle("H2G2");
assertEquals("Title should be H2G2", "H2G2", book.getTitle());
tx.commit();
tx.begin();
book = em.find(BookCustomized.class, book.getId());
assertEquals("Title should be The Hitchhiker's Guide to the Galaxy", "The Hitchhiker's Guide to the Galaxy", book.getTitle());
tx.commit();
}