Andrew Spiteri

+ Follow
since Jan 25, 2020
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Andrew Spiteri

I solved this by removing withRouter() from my component.  I don't need to use it since I'm using React Router v5.1.

I can access history simply through the useHistory hook.
I'm building a React front end with a Spring back end.  I'm using React Router and Redux.  When I try to switch pages I get this error:

TypeError: Cannot read property 'wrappedComponentRef' of null

I've looked around and it has something to do with the withRouter() of React Router.  I think it's saying that my Component is null.  It's a functional component.  Here's the code.


I have a test method testing admin privileges for a put method in my controller, which updates the my Route entity in a JPARepository.  I added some logic to the controller to test if the update returns successfully by returning how many records were updated.  It returns a 400 if the Integer returned is <1.  Since I added that logic my unit test refuses to pass.  I'm wondering what about the logic is making it so that it always returns a 400?  Is my test written incorrectly?

Test Code:

Controller Code:

1 month ago
I'm creating a table that's supposed to hold books.  The foreign key is the authorId and I want it to cascade on delete.  I'm using Oracle 11g.  Whenever I run this I get an error saying: ORA-00905: missing keyword

The tutorials I'm using say the syntax is correct.  This is where I've gone thus far:

Here's the statement I've written:

I'm getting an error message in Tomcat.  It's saying a field isn't mapped to a table in one of my classes.  Here's the exception message.  I can provide the rest of the stacktrace later, if you want.

nested exception is org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class:[java.lang.Integer]

I'm trying to create a join table between users and movies to represent movies that people like.  Hibernate seems to be telling me the List I've created in my MovieLikes class isn't mapped to a table.  I only want the field included in a join table, though.  Here's the code for

4 months ago
testRegister returns a Boolean to indicate to the servlet if the user was successfully registered, otherwise it serves a 500 status code.

That code was redundant, thank you.

ERS is upper case because it's an acronym for Employee Reimbursement System.

The dot operators in the conditional were necessary because that method returns an Optional so I can forego returning a null.  It's just doing null checking on the username to see if it's available.


As for issues I'm having with the tests, in testRegister the isUserValid method is is throwing an InvalidRequestException even though I have mocking code that, I believe should handle the isUserValid method.

I've tried this 2 ways, with a mocked ERS_Users variable and with an ERS_Users variable that's actually instantiated.  It's line 3 in testRegister that throws the exception:

I mocked the user variable like this:

and I create the real ERS_Users object like this:

5 months ago
I have 2 JUnit tests out of 7 that are failing on me.  I can't seem to pinpoint how to fix the code or rework the tests so they'll pass.  I'm not experiencing any errors with the code the unit tests are testing.

1st unit test:

2nd unit test:

5 months ago
This is the answer I eventually ended up getting to work.  I turned it into an UPDATE statement instead of SELECT INTO.

I'm trying to invoke the procedure in sql developer using this statement:

It's giving me this response, though:

ORA-00904: "ERS_APP"."UPDATE_REIMBS": invalid identifier
00904. 00000 -  "%s: invalid identifier"
Error at Line: 1 Column: 8

I'm going to try testing it another way but if anyone has suggestions I'm open to them.
It's not updating the reimb_status_id like I need it to.  

I say:

The reimb_status_id doesn't update and the execute statement returns false.  I'm not sure how to debug this.  I think I need to run the procedure in sql developer to see what's wrong but I'm not good with stored procedures.  I don't know what to run to execute it.
I'm still having issues with the Callable Statement.  Now it compiles but it returns false when it executes from Java.  Here's what the stored procedure looks like:

and here's what my java code looks like, (the PreparedStatement is commented out b/c this needs to be a CallableStatement according to my trainer):

That wasn't a correct answer, just a correction.  I'm sorry for misleading you.

I'm still receiving compiler errors:

3/1       : Encountered the symbol "DECLARE" when expecting one of the following:     begin function pragma procedure subtype type <an identifier>    <a double-quoted delimited-identifier> current cursor delete    exists prior external language The symbol "begin" was substituted for "DECLARE" to continue.

11/0     : Encountered the symbol "end-of-file" when expecting one of the following:     ( begin case declare end exception exit for goto if loop mod    null pragma raise return select update while with    <an identifier> <a double-quoted delimited-identifier>    <a bind variable> << continue close current delete fetch lock    insert open rollback savepoint set sql execute commit forall    merge pipe purge

Errors: check compiler log
I just realized I need a where clause in the statement:

I'm creating a stored procedure to use in a CallableStatement and I'm kind of lost as to how to write it.  This is what I have thus far:

It's refusing to compile.  I've tried a couple different things but I think it's coming down to not understanding the rules behind the syntax for stored procedures.  

I need the procedure to update the status id in the ers_reimbursement table.  The procedure takes a value from the Java code that represents the new status id.
I realized the problem.  I wasn't in the root where my pom.xml was when I was trying to build the project.

5 months ago