views:

341

answers:

2

I have made an application using Java/Hibernate/MySQL, but whenever I try running it, it complains that the table for one of my entity classes has not been created.

After some trial and error, I have come to the conclusion that the problem is coming from the way I am mapping embedded components, but I do not know how I may fix it.

Here are the relevant bits of code:

@Entity
public class Feed {
... //Definition of some properties
  @Embedded
  @AttributeOverrides( {
    @AttributeOverride(name = "type", column = @Column(name = "title-type")),
    @AttributeOverride(name = "mode", column = @Column(name = "title-mode")),
    @AttributeOverride(name = "value", column = @Column(name = "title-value")) })
  public Content getTitle() { ... }

  ...
}

@Embeddable
public class Content {
  ... // There are three properties with bean syntax
      // without any persistence annotation.
}

Does anyone know why Hibernate fails to create the table for the class Feed? And how I may correct it?

Thank you in advance.

Edit: Finally, I have understood; the fact that I used "-" characters in my columns was to blame. I replaced these with underscores and all is well again.

Thank you very much for your help.

A: 

you sure you Override all of your Embeddable Class Properties(Although it must work when you don't override all) When I compare your code with mine I have seen no difference (I just implement Serializable for my class) can you write what exception it throw?

Am1rr3zA
A: 

Excuse me for the lack of updates, but I have finally been able to log the necessary debug information.

The names I had chosen for my columns were at fault; I would guess that the "-" is reserved for arithmetic operations and that it should not be in a column name.

I replaced them with underscores, and that problem is solved.

Thank you very much for your help.

jhominal