Results 1 to 2 of 2
  1. #1
    kattoha is offline Member
    Join Date
    Apr 2014
    Posts
    13
    Rep Power
    0

    Default Hibernate and @PrimaryKeyJoinColumn and its strange behaviour

    Hello, Community. I have a question. I have two entities:
    Article:
    Java Code:
    @Entity
    @Table(name = "articles_all")
    public class Article extends BaseEntity {
        @Id
        @GeneratedValue
        @Column(nullable = false, unique = true, length = 11)
        private int id;
        @Column(nullable=false, length=255)
        private String title;
        @Lob
        private byte[] content;
        @ManyToOne
        private UsersEntity author;
    
        @OneToOne(mappedBy="article", cascade=CascadeType.ALL)
        private Archive archive;
    }
    and Archive:
    Java Code:
    @Entity
    @Table(name="archive")
    public class Archive {
        @GenericGenerator(name="generator", strategy="foreign", parameters=@Parameter(name="property", value = "article"))
        @Id
        @GeneratedValue(generator="generator")
        private int articleId;
        @OneToOne
        @PrimaryKeyJoinColumn
        private Article article;
    }
    When I run application with this configurations, all tables in database are create automatically, so I have 'archive' table with foreign primary key, but when I try to add one more field into Archive entity (any field), tables didn't create, but works with manually created table (but my goal - automation). (All actions were used on database with dropped tables) .
    What does it mean? Is it a bug or it is normal behaviour?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Hibernate and @PrimaryKeyJoinColumn and its strange behaviour

    Moved from New to Java to Hibernate.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. very Strange behaviour !!
    By selimzz in forum Advanced Java
    Replies: 12
    Last Post: 01-06-2013, 11:35 AM
  2. Strange JFrame behaviour
    By javaExprt in forum New To Java
    Replies: 5
    Last Post: 12-24-2012, 03:20 AM
  3. Strange behaviour
    By imadabh in forum Threads and Synchronization
    Replies: 1
    Last Post: 05-11-2011, 03:31 PM
  4. Strange JVM behaviour
    By pjpr in forum Advanced Java
    Replies: 13
    Last Post: 01-03-2011, 07:39 PM
  5. AffinedTransform strange behaviour
    By Echilon in forum AWT / Swing
    Replies: 3
    Last Post: 12-11-2008, 09:58 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •