[jboss-user] [EJB 3.0] - Re: NOT NULL columns with a DEFAULT

oskar.carlstedt do-not-reply at jboss.com
Thu Apr 12 11:18:05 EDT 2007


Hi!!

No It is not exactly what I want. I solved everything by using inheritance and the SINGE_TABLE inheritance method. Then I could skip my property I didn't want to include.

But originally, I have a database specifying the default value. This value is used by other applications too. So to centralize the default value, we declared it in the database - Therefore, I don't want to set the default value in my implementation. Maybe this is something to report as a new annotation for ejb3. I don't think I'm the only one that is modeling a persistence layer on an existing database.

Anyway, I resolved my problem by using inheritance.

  | @Entity
  | @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
  | @DiscriminatorColumn(name = "discriminator", discriminatorType = DiscriminatorType.STRING)
  | @Table(name = "THE_TABLE")
  | public class GenericEntityBean implements Serializable {
  | 
  | 	@Id
  | 	@Column(name = "id")
  | 	@GeneratedValue(strategy = GenerationType.IDENTITY)
  | 	protected Integer id;
  | 
  | 	@Column(name = "COMMON_VALUE")
  | 	protected String commonValue;
  | 
  | 	...
  | }
  | 
  | 
  | @Entity
  | @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
  | @DiscriminatorColumn(name = "discriminator")
  | @DiscriminatorValue(name = "SPECIFIC")
  | public class SpecificEntityBean extends GenericEntityBean implements Serializable {
  | 
  | 
  | 	@Column(name = "ANOTHER_SPECIFIC_VALUE")
  | 	protected String anotherSpecificValue;
  | 
  | 	...
  | }
  | 
  | 

Best Regards
Oskar


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4036770#4036770

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4036770



More information about the jboss-user mailing list