Solved

sequence error

Posted on 2014-04-22
4
312 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

705 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