Solved

sequence error

Posted on 2014-04-22
4
299 Views
Last Modified: 2014-04-28
hello,

I have a class with jpa annotation called WebdUserRight and have a controller which is below this class.. when i pass the code and description from a jsp it gives me  error as sequence does not exist as
The code breaks at the     "em.persist(webdUserRight);" with the above error. but i have
access rights of the sequence generator.. what could be the issue on this piece of code

[TopLink Warning]: 2014.04.23 09:09:07.875--ClientSession(4731775)--Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: ORA-02289: sequence does not exist

Error Code: 2289
Call: SELECT user_webdUser_seq.NEXTVAL FROM DUAL
Query: ValueReadQuery()

Open in new window


@Entity
@Table( name="user_webdUserRight")
public class WebdUserRight {
  
  @SequenceGenerator( name = "user_webdUser_seq", sequenceName = "user_webdUser_seq", allocationSize = 1 )
  @GeneratedValue( strategy = GenerationType.SEQUENCE, generator = "user_webdUser_seq" )    
  @Id
  @Column
  private int webdUserRightKey;
  
  @Column
  private String code;
  
  @Column
  private String descrip;
  
 public String getCode() {
    return code;
  }

  public void setCode( String code ) {
    this.code = code;
  }

  public String getDescrip() {
    return descrip;
  }

  public void setDescrip( String descrip ) {
    this.descrip = descrip;
  }

  public int getWebdUserRightKey() {
    return webdUserRightKey;
  }

  public void setWebdUserRightKey( int webdUserRightKey ) {
    this.webdUserRightKey = webdUserRightKey;
  }

Open in new window


@Controller
public class RightsController {
@RequestMapping(value = "addRights")
		public String saverights(
				HttpServletRequest request, 
				HttpServletResponse response,
				@ModelAttribute("WebdUserRight") WebdUserRight webdUserRight,
				@RequestParam("code") String Strcode,
				@RequestParam("name") String Strname,
				Model model) {
			
			

		
		
			EntityManager em = DataAccess.emf.createEntityManager();
		
			
			try {
			
			
				em.getTransaction().begin();
			
				webdUserRight.setCode(Strcode);
				webdUserRight.setDescrip(Strname);
			
				
				em.persist(webdUserRight);
				em.getTransaction().commit();

				return "user/mainRights";
			} catch (Exception e) {
				return "failure";
			} finally {
				em.close();
			}
		}
		
  }
}			

Open in new window

0
Comment
Question by:roy_sanu
  • 2
  • 2
4 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 40016900
Are you sure that a sequence with the name "user_webdUser_seq" exists in the database?
0
 

Accepted Solution

by:
roy_sanu earned 0 total points
ID: 40016975
schema.user_webdUser_seq was missing in the code it is working now

thanks
0
 
LVL 37

Expert Comment

by:zzynx
ID: 40016993
>> the code it is working now
Okay!
Kindly close this question.

>> thanks
You're welcome.
0
 

Author Closing Comment

by:roy_sanu
ID: 40026828
working after adding schema to the code
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now