Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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] Thu, 24 October 2013 00:43 Go to next message
nuno pinto is currently offline nuno pintoFriend
Messages: 5
Registered: October 2013
Junior Member
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 16:09 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
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 16:12 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
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 18:18 Go to previous message
nuno pinto is currently offline nuno pintoFriend
Messages: 5
Registered: October 2013
Junior Member
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 18:19]

Report message to a moderator

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


Current Time: Thu Apr 25 14:17:19 GMT 2024

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

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

Back to the top