Friday, May 31, 2013
Could not autowire field
This is mostly a note to myself, but maybe this will also help someone else along the way. I have a problem with forgetting to add the annotation @Repository to the top of my Dao classes. When I forget to do this, I ALWAYS get a "Could not autowire" error. Then I clean, rebuild, and republish for like an hour thinking that will solve the problem. Well, guess what?!?! That's not the solution! ADD THE ANNOTATION!
Thursday, May 30, 2013
java.math.BigDecimal cannot be cast to java.lang.Boolean
I have a table that has a column with a value of either -1 or 0 depending on if that row item is default or not. What it returns in my query is a BigDecimal. Well guess what? I don't want a BigDecimal, I want a boolean! I have to admit, it was near the end of the day and I just wanted to get this knocked out, so I didn't really try searching all over Stack Overflow this time for the answer. I emailed a coworker and this is how I fixed the problem:
for (Object[] item : unorganizedList){
AssignedLimitDefaults assignedLimitDefaultsItem = new AssignedLimitDefaults();
//accept it as a BigDecimal (because that's how it is returned), then take its
//integer value (because it's just going to be -1 or 0 anyway)
//and if it's anything but 0 it will return true and if it's 0 it will return false
assignedLimitDefaultsItem.setIndDefault(((BigDecimal) item[0]).intValue() != 0);
assignedLimitDefaultsItem.setNmeLimit(item[1].toString());
assignedLimitDefaultsItem.setCdeLimit(item[2].toString());
assignedLimitDefaultsList.add(assignedLimitDefaultsItem);
}
As you can see, I have an array of Objects that I'm iterating through to create a new object called assignedLimitDefaultsItem. I had to create a whole new object because I have info coming back from my query that comes from two different tables. One Hvo object just didn't do the job. It had never occurred to me before this project that I'm working on now that when I need some info from the db I can just cherry-pick the columns I want and I don't have to use the Hvo objects that are already provided. If you'd like a detailed example, just ask and I'll make a new post about it!
for (Object[] item : unorganizedList){
AssignedLimitDefaults assignedLimitDefaultsItem = new AssignedLimitDefaults();
//accept it as a BigDecimal (because that's how it is returned), then take its
//integer value (because it's just going to be -1 or 0 anyway)
//and if it's anything but 0 it will return true and if it's 0 it will return false
assignedLimitDefaultsItem.setIndDefault(((BigDecimal) item[0]).intValue() != 0);
assignedLimitDefaultsItem.setNmeLimit(item[1].toString());
assignedLimitDefaultsItem.setCdeLimit(item[2].toString());
assignedLimitDefaultsList.add(assignedLimitDefaultsItem);
}
As you can see, I have an array of Objects that I'm iterating through to create a new object called assignedLimitDefaultsItem. I had to create a whole new object because I have info coming back from my query that comes from two different tables. One Hvo object just didn't do the job. It had never occurred to me before this project that I'm working on now that when I need some info from the db I can just cherry-pick the columns I want and I don't have to use the Hvo objects that are already provided. If you'd like a detailed example, just ask and I'll make a new post about it!
Tuesday, May 28, 2013
403 Forbidden!!
Yuck. What is going on with that?! Everything was going fine until I try to save to my database! I looked all over Stack Overflow before posting a question... and getting a response from John, who sits across from me at work:
http://stackoverflow.com/questions/16718701/403-forbidden-returned-when-attempting-to-save-to-database
I had encountered this problem before and I didn't write down what the fix was, or where the problem even came from. No we'll all know what to do! ResponseMap!!! & produces = "application/json".
http://stackoverflow.com/questions/16718701/403-forbidden-returned-when-attempting-to-save-to-database
I had encountered this problem before and I didn't write down what the fix was, or where the problem even came from. No we'll all know what to do! ResponseMap!!! & produces = "application/json".
Friday, May 24, 2013
No Hibernate Session bound to thread
Here's my error:
{"message":"No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here","success":false}
I've looked all over Stack Overflow (which I find to be a fantastic site for questions and answers). Then before posting a question there, I looked at the message, specifically where it says "configuration does not allow creation of non-transactional one here." I thought to myself and then looked down at one of several sticky notes I have on my monitor stands... "Annotate" it says. Hmmm.
Where have I seen something about "Transactional" before? OH! It's an annotation! So I added @Transactional to my Dao method that the system was getting hung up on and viola!! Success. Application starts up like normal now! **feeling smart**
Here is the link to my Stack Overflow profile in case you're interested:
http://stackoverflow.com/users/2383389/robyn-paxton
I plan on posting questions there and also commenting in this blog about it. You're also welcome to ask questions about what I'm doing or about a problem you've encountered. I'd be happy to help in any way I can!
{"message":"No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here","success":false}
I've looked all over Stack Overflow (which I find to be a fantastic site for questions and answers). Then before posting a question there, I looked at the message, specifically where it says "configuration does not allow creation of non-transactional one here." I thought to myself and then looked down at one of several sticky notes I have on my monitor stands... "Annotate" it says. Hmmm.
Where have I seen something about "Transactional" before? OH! It's an annotation! So I added @Transactional to my Dao method that the system was getting hung up on and viola!! Success. Application starts up like normal now! **feeling smart**
Here is the link to my Stack Overflow profile in case you're interested:
http://stackoverflow.com/users/2383389/robyn-paxton
I plan on posting questions there and also commenting in this blog about it. You're also welcome to ask questions about what I'm doing or about a problem you've encountered. I'd be happy to help in any way I can!
Thursday, May 23, 2013
New Plan
My initial idea was to go back to my first project and share what I went through with that experience and everything that I learned... in a cohesive timeline. As each day goes by that I haven't updated this blog, I understand that I can't go back in time and recreate the project process in the order in which the events occurred. I wish I could go back to the start of that project and start the blog *then*. Unfortunately that is not an option.
I have decided to go with my new plan, which makes more sense to me. I'm going to write about things that happen in as close to real time as I can get it. Some things may have to wait until the end of the day, and maybe I can post some things at lunch, depending on what's blowing up on me at the time. I think I might be able to also talk about that first project sprinkled throughout my other posts.
A *real* update is coming soon. I promise.
I have decided to go with my new plan, which makes more sense to me. I'm going to write about things that happen in as close to real time as I can get it. Some things may have to wait until the end of the day, and maybe I can post some things at lunch, depending on what's blowing up on me at the time. I think I might be able to also talk about that first project sprinkled throughout my other posts.
A *real* update is coming soon. I promise.
Friday, May 17, 2013
My first web app.
The first project I was assigned was basically to make a CRUD table. At first I though, oh great, you're giving me a project that is so beneath you that you think it's crap. Crud table. Great. Now I know better. For those of you that don't know, CRUD stands for Create, Read, Update, Delete. Had I known this from the start I wouldn't have been so offended!
The purpose of this was to update a database that has all the information about zip codes and our insurance rating territories. We have a subscription with a company that sends us zip codes as they get updated with the postal service. When new ones are added, our different underwriting divisions will go in and add a rating territory to each new zip code. Sounds simple enough, right? In theory, yeah. In practice? Not so much.
I had never worked with SQL Developer or Eclipse, which are the main two programs I use EVERY DAY now to make projects work (aside from Firefox and Firebug). Getting set up to even *use* Eclipse took almost two days. There was error after error after error. Now that everything has been set up, I have several .xml files and .conf files saved for a quick start. And one developer here started an empty project that was pretty much an idiot proof way to start a project (which I've used on all three of my projects so far).
Once setup was complete, it was down to the nitty gritty. Here is where I was introduced to MVC architecture. I had taken one introductory Java class prior to starting this project which basically taught me public static void main... command line Java. Boy was I in for a surprise when I saw that I had to pass information/commands/methods through LAYERS. Mind.blown.
It took me about a month to successfully finish up with this project, and in several more posts, I'll go back through my notes (and there are lots of them) and tell you what I've learned.
The purpose of this was to update a database that has all the information about zip codes and our insurance rating territories. We have a subscription with a company that sends us zip codes as they get updated with the postal service. When new ones are added, our different underwriting divisions will go in and add a rating territory to each new zip code. Sounds simple enough, right? In theory, yeah. In practice? Not so much.
I had never worked with SQL Developer or Eclipse, which are the main two programs I use EVERY DAY now to make projects work (aside from Firefox and Firebug). Getting set up to even *use* Eclipse took almost two days. There was error after error after error. Now that everything has been set up, I have several .xml files and .conf files saved for a quick start. And one developer here started an empty project that was pretty much an idiot proof way to start a project (which I've used on all three of my projects so far).
Once setup was complete, it was down to the nitty gritty. Here is where I was introduced to MVC architecture. I had taken one introductory Java class prior to starting this project which basically taught me public static void main... command line Java. Boy was I in for a surprise when I saw that I had to pass information/commands/methods through LAYERS. Mind.blown.
It took me about a month to successfully finish up with this project, and in several more posts, I'll go back through my notes (and there are lots of them) and tell you what I've learned.
Initial import.
I've been in my position as a Junior Developer at my job for around three months now. Something told me that I should blog about this experience because it may serve as a helpful tool for someone else just beginning their career as a Java Developer. I had a LOT of questions when I started and getting set up is probably the hardest part. Thankfully my team is excellent at answering my questions and the guys I work with are extremely patient with me.
My goal here is to post about problems I have encountered and the solutions I have found for them. I am positive that for anyone just starting out this will save a lot of headache if you save this blog, comment on it if you have questions, and use it as another resource in your quest to be an amazing Java programmer.
I intend to talk about Spring Architecture, Hibernate, Java, Javascript, CSS, Tomcat, Eclipse, object-oriented programming, MVC, web services, and anything else that I encounter at work that may serve as an educational experience for you so that maybe if you run into the same problems I did, you won't be stuck for very long.
Welcome to my blog. I hope you find this a useful tool!
My goal here is to post about problems I have encountered and the solutions I have found for them. I am positive that for anyone just starting out this will save a lot of headache if you save this blog, comment on it if you have questions, and use it as another resource in your quest to be an amazing Java programmer.
I intend to talk about Spring Architecture, Hibernate, Java, Javascript, CSS, Tomcat, Eclipse, object-oriented programming, MVC, web services, and anything else that I encounter at work that may serve as an educational experience for you so that maybe if you run into the same problems I did, you won't be stuck for very long.
Welcome to my blog. I hope you find this a useful tool!
Subscribe to:
Posts (Atom)