Solved

sequence error

Posted on 2014-04-22
4
293 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
Comment Utility
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
Comment Utility
schema.user_webdUser_seq was missing in the code it is working now

thanks
0
 
LVL 37

Expert Comment

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

>> thanks
You're welcome.
0
 

Author Closing Comment

by:roy_sanu
Comment Utility
working after adding schema to the code
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
countHi2 challenge 7 43
topping3 challenge 14 48
Securing Jmx Console and web console 2 45
thymeleaf natural templating vs JSP 2 23
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

771 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

10 Experts available now in Live!

Get 1:1 Help Now