Solved

sequence error

Posted on 2014-04-22
4
302 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
tomcat startup error 5 102
eclipse buid path vs tomcat lib path 10 34
Html Table Looping (part 2) 5 27
running on tomcat not jboss eap 7.0 3 18
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

839 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