Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » EclipseLink seems to ignore columnDefinition and nullable(columnDefinition and nullable parameters on @JoinColumn are ignored)
EclipseLink seems to ignore columnDefinition and nullable [message #1152367] Wed, 23 October 2013 20:43 Go to next message
Eclipse UserFriend
EclipseLink 2.5 seems to be ignoring columnDefinition and nullable when generating DDL to a PostgreSQL database.

My code:

User.java

public class User implements Serializable {
  @Id
  @Column(name = "id", columnDefinition = "bigserial")
  private Long id = null;
}


UserProfile.java

public class UserProfile implements Serializable {
  @OneToOne
  @JoinColumn(name = "invited_by", columnDefinition = "bigint", nullable = true)
  private User invitedBy = null;
}


UserProfile should be created with the field invited_by such as invited_by bigint but instead it is generating

invited_by bigserial not null


Is this a bug or am I doing it wrong? The same code works with Hibernate.

Thanks
Re: EclipseLink seems to ignore columnDefinition and nullable [message #1154994 is a reply to message #1152367] Fri, 25 October 2013 12:09 Go to previous messageGo to next message
Eclipse UserFriend
EclipseLink uses the columnDefinition as is to override any settings, so that explains why the nullable would be ignored - similar to https://bugs.eclipse.org/bugs/show_bug.cgi?id=279503

I could not find a bug filed for EclipseLink using the referenced field's columnDefinition, so you may want to file one if it is still not fixed in the 2.5.1 or 2.6 releases. A workaround would be to use a descriptor customizer to manually define the DatabaseField object used in the invitedBy OneToOneMapping.
Re: EclipseLink seems to ignore columnDefinition and nullable [message #1155000 is a reply to message #1154994] Fri, 25 October 2013 12:12 Go to previous messageGo to next message
Eclipse UserFriend
Another workaround is to avoid using the columnDefinition as described in this answer:
http://stackoverflow.com/questions/9284564/eclipselink-postgresql-doesnt-use-bigserial-to-long-id
Re: EclipseLink seems to ignore columnDefinition and nullable [message #1155137 is a reply to message #1152367] Fri, 25 October 2013 14:18 Go to previous message
Eclipse UserFriend
Thanks for the replies. I've seen both the stackoverflow link and the mentioned bug report. I really wanted to use serial types because the database is going to be used by more applications. This bug made me rethink my approach and I decided to code the database first (as it is the core component of the system) and let eclipselink generate entities from it. So far I am happy with this approach.

I do believe it is a bug though. It generates serial columns to foreign keys, which can never be, and doesn't allow to override. However as I changed my code and won't be able to keep an eye on it I'm not sure if I should start a bug report which I won't be following.

Thanks

[Updated on: Fri, 25 October 2013 14:19] by Moderator

Previous Topic:Coonection timesout after 8 hours
Next Topic:Issues with uow.getOriginalVersionOfObject(workingClone)
Goto Forum:
  


Current Time: Tue Jul 22 19:33:16 EDT 2025

Powered by FUDForum. Page generated in 0.04574 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top