-->
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.  [ 3 posts ] 
Author Message
 Post subject: Column annotation ignored depending on target
PostPosted: Thu Mar 01, 2007 12:10 pm 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
Hibernate Annotations 3.2.1 GA

I found that the column annotation is sometimes ignored. The reason is that I mixed column annotations targets. I assigned the ID to the field and the other annotations to a method.

If the ID annotation is assigned to a field, further method annotations are ignored and vice versa.

I am not sure if this should be filed as a bug and appreciate feedback on this problem.

Regards Sebastian
Code:
package de.laliluna.annotation;

import java.io.Serializable;
@Entity
public class SimpleBean implements Serializable {

    public static void main(String[] args) {
   new SchemaExport(new AnnotationConfiguration().configure()).create(true, false);

    }

    @Id
    private Integer id;

    private String nameMethod;

    @Column(name = "name_field")
    private String nameField;

    public Integer getId() {
   return id;
    }

    public void setId(Integer id) {
   this.id = id;
    }

    public String getNameField() {
   return nameField;
    }

    public void setNameField(String nameField) {
   this.nameField = nameField;
    }

    @Column(name = "name_method")
    public String getNameMethod() {
   return nameMethod;
    }

    public void setNameMethod(String nameMethod) {
   this.nameMethod = nameMethod;
    }

}


[/code]

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 01, 2007 12:13 pm 
Senior
Senior

Joined: Tue Jul 25, 2006 9:05 am
Posts: 163
Location: Stuttgart/Karlsruhe, Germany
Hi,

This is a know issue/feature, you should really try and keep your annotations at either field or getter level as you will run into big problems (especially with relationships) if you mix.


Cheers,

Andy

_________________
Rules are only there to be broken


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 07, 2007 7:22 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This is a feature. Do not mix and match annotated getters and attributes

_________________
Emmanuel


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

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.