-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Embedded Components - not working
PostPosted: Sat Jul 25, 2009 4:25 pm 
Newbie

Joined: Sat Jul 25, 2009 3:44 pm
Posts: 1
Hello,

I have had some problems embedding components for my project, using Java Persistence Annotations and MySQL.

More specifically, Hibernate does not throw any exception while building the tables, however, Hibernate does not create the corresponding table, thus eventually throwing "table does not exist" exceptions.

This behaviour happens with the following code:
Code:
@Entity
public class TestEmb {
  private Long id;
  private ImageReference image;
  private String name;
 
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  public Long getId() {
    return id;
  }
  @SuppressWarnings("unused")
  private void setId(Long id) {
    this.id = id;
  }

  @Embedded
  public ImageReference getImage() {
    return image;
  }
  public void setImage(ImageReference image) {
    this.image = image;
  }
}

@Embeddable
public class ImageReference {
  private String title;
  private String url;
  private String link;
  private String description;

  @Column(name = "image-title", length = 255)
  public String getTitle() {    /* Standard getter/setter code omitted */ }
  @Column(name = "image-url", length = 255)
  public String getUrl() {    /* Standard getter/setter code omitted */ }
  @Column(name = "image-link", length = 255)
  public String getLink() {    /* Standard getter/setter code omitted */ }
  @Column(name = "image-description", length = 255)
  public String getDescription() {    /* Standard getter/setter code omitted */ }
}

I have only been able to verify that as soon as I comment the references to the "image" field (field, getter and setter + annotations), the table for "TestEmb" would appear in the database.
I have been unable to understand what was going wrong, and I would like to have your help:
-Do you have an idea of what could be wrong with the code/project setup/whatever else ?
-How can I make Hibernate throw an exception, or at least a message, detailing why it could not create a table rather than let it fail silently? (I am using slf4j and log4j)

Thank you in advance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.