• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DAO method can not save Image

 
wladimir bandeira
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My class bean can already save the image in my specific directory, I know this because I auditioned, but only lack he can save the String that is the filename that do FileUpload in the database

I'll show part of the produto entity





It contains other attributes and also contains the Getts and setts attribute image.

this is the bean class I'm trying to save the image of the string on the bench





This is the piece of code I'm having trouble




I'm trying to change this method to write the image name in the bank, and I'm not getting





I am using a JSF project with a Hibernate DAO model.

 
Tim Holloway
Saloon Keeper
Posts: 18367
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had to think about this for a while. Anytime examples are too big to all fit on the screen at one time it makes for a lot more work to make sense of them. And since we don't get paid to do this, a lot of times it's not worth the effort.

I did notice one curious thing, though:


It would appear that you are attempting to set a query parameter, but instead of indicating the parameter name, you'd specified "null".
 
wladimir bandeira
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not want to visit, I want to modify the method gravarImagem to be able to save the image name in the bank.

Now you could understand?
 
Tim Holloway
Saloon Keeper
Posts: 18367
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're not "visiting" when your Query string's JPQL is an INSERT statement. "Query" in that particular case refers to Query Language, not whether your are querying or saving it.

Therefore if there is a variable parameter, you MUST set it, either by symbolic name or by its (1-based) index value.

So, for example, with an unnamed ("?") parameter, you should be doing something like this:



Actually, none of that makes sense. Hibernate is an ORM system, you should be working with an ORM model object (which, if you're updating would have to have been fetched), setting the properties you want to be written out, then doing a Hibernate session save or update to persist the new values out to the database.

JSF doesn't have any database logic at all in it. Anything you do with databases is not of its concern, so if something works without JSF it should work with JSF.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic