-->
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.  [ 2 posts ] 
Author Message
 Post subject: cannot find symbol - Id GeneratorType.S
PostPosted: Mon Apr 09, 2007 3:12 pm 
Newbie

Joined: Thu Jun 22, 2006 7:22 am
Posts: 2
Hibernate version: 3.2
Name and version of the database you are using: postgresql 8.2

hi!

I have problems defining persistence indentity for attribute. Where is the problem? I used an hibernate example but it seems not work - can't find symbol! Any idea?

Tx for help.


The build script outputs following
Code:
Buildfile: D:\Softi Projects\eclipse workspace\SpringApp\build.xml
build:
    [javac] Compiling 7 source files to D:\Softi Projects\eclipse workspace\SpringApp\war\WEB-INF\classes
    [javac] D:\Softi Projects\eclipse workspace\SpringApp\src\org\annotationmvc\vo\MyObjectVO.java:40: cannot find symbol
    [javac] symbol  : method generate()
    [javac] location: @interface javax.persistence.Id
    [javac] @Id (generate = GeneratorType.AUTO)
    [javac] ^
    [javac] D:\Softi Projects\eclipse workspace\SpringApp\src\org\annotationmvc\vo\MyObjectVO.java:40: cannot find symbol
    [javac] symbol  : variable GeneratorType
    [javac] location: class org.annotationmvc.vo.MyObjectVO
    [javac] @Id (generate = GeneratorType.AUTO)
    [javac] ^
    [javac] 2 errors

BUILD FAILED
D:\Softi Projects\eclipse workspace\SpringApp\build.xml:52: Compile failed; see the compiler error output for details.

Total time: 3 seconds



Code:
package org.annotationmvc.vo;

import java.io.*;
import javax.persistence.*;

@Entity
@Table (name="myobject")
public class MyObjectVO implements Serializable {

    private int id;
    private String name;
    private String address;
    private String email;
    private String phone;

    public MyObjectVO() {
    }

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

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

    public void setAddress(String address) {
        this.address = address;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    @Id (generate = GeneratorType.SEQUENCE)
    public int getId() {
        return id;
    }

    @Column (length=100)
    public String getName() {
        return name;
    }

    @Column (length=100)
    public String getAddress() {
        return address;
    }

    @Column (length=30)
    public String getEmail() {
        return email;
    }

    @Column (length=15)
    public String getPhone() {
        return phone;
    }

}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 09, 2007 3:52 pm 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
"generate" is not a valid data member of that @Id annotation. @Id does'nt have any data members. You will have to use a combination of @GeneratedValue,@GenericGenerator to achieve it. Here's an example using the Hibernate Generic Generator Annotation:
Code:
   @Id @GeneratedValue(generator="increment")
   @Column(name="APP_ID")
   @GenericGenerator(name="increment",strategy="increment")

A JPA/EJB3 only annotation might look something like this:
Code:
   @Id @GeneratedValue(strategy=SEQUENCE)
                @SequenceGenerator(name="mySeq",sequenceName="mySeq")
   @Column(name="APP_ID")

_________________
--------------
Don't forget to Rate the post


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.