-->
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: @AttributeOverride not working
PostPosted: Fri Apr 12, 2013 11:31 am 
Newbie

Joined: Fri Apr 12, 2013 11:19 am
Posts: 2
Hi all,

I have the code

Code:
@MappedSuperclass
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@XmlAccessorType(XmlAccessType.FIELD)
public abstract class AbstractModel implements Serializable, Comparable<AbstractModel> {

    private static final long serialVersionUID = -4479726024447228668L;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "idgen")
    private Long              id;
    ...


@MappedSuperclass
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@XmlAccessorType(XmlAccessType.FIELD)
public abstract class AbstractHistoricModel extends AbstractModel {

    private static final long     serialVersionUID = -3596885940998632065L;

    @Column(name = "pblc_id")
    ...


@Entity
@SequenceGenerator(initialValue = 0, name = "idgen", sequenceName = "abstract_claim_type_seq")
@XmlAccessorType(XmlAccessType.FIELD)
public class AbstractClaimType extends AbstractHistoricModel {

    private static final long serialVersionUID = -3840541568639732203L;

    @Column(name = "nam")
    private String            name;

    public AbstractClaimType() { super(); }

    @Field
    public String getName() {
       return name;
    }

    public void setName(String name) {
       this.name = name;
    }
    ...


@Entity
@Table("retr_clm_mthd")
@SequenceGenerator….
@FieldModel
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
[b]@AttributeOverride(name="name", column=@Column(name="retr_clm_mthd_nam", length=255))  [/b]
public class Retrospective extends AbstractClaimType {
...


and when I create the database in memory to test

Code:
2013-04-11 14:15:28,445 ERROR (org.hibernate.tool.hbm2ddl.SchemaExport:org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:386))  - HHH000231: Schema export unsuccessful

org.hibernate.tool.hbm2ddl.ImportScriptException: Error during statement execution (file: '/import.sql')

Caused by: java.sql.SQLException: Column not found: RETR_CLM_MTHD_NAM in statement


I look the scriptdb and there is


CREATE MEMORY TABLE RETR_CLM_MTHD(…., NAM VARCHAR(255), ….)

Why not retr_clm_mthd_nam? What is wrong?

Regards & thanks


Top
 Profile  
 
 Post subject: Re: @AttributeOverride not working
PostPosted: Mon Apr 15, 2013 4:43 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
I would do a try with specifying "nam" instead to "name":

@AttributeOverride(name="nam", column=@Column(name="retr_clm_mthd_nam", length=255))


Top
 Profile  
 
 Post subject: Re: @AttributeOverride not working
PostPosted: Mon Apr 15, 2013 5:37 am 
Newbie

Joined: Fri Apr 12, 2013 11:19 am
Posts: 2
Hi,

The result is the same.

Attribute Override is used to override the mapping of an attribute name. Not a database column name.

http://docs.oracle.com/javaee/6/api/javax/persistence/AttributeOverride.html

Regards


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.