I am quite new to Hibernate, and I would like to get the last N characters of a string. I found the substring method, but that didn't really help :(
Does anyone have any idea?
TIA
I am quite new to Hibernate, and I would like to get the last N characters of a string. I found the substring method, but that didn't really help :(
Does anyone have any idea?
TIA
I hit this problem not too long ago resolved it, hit it again and returned back to how I resolved it a few weeks back.
Assuming as an example you are uploading a file. The file will go to something like
/tmp/user/1/image.jpg
orc:\temp\user\1\image.jpg
The upload process needs to be written in a way that the actual path for image storage is generated for it and can be regenerated so assuming our path isWhen attempting to do our HQL we need to be able to extract what is not actual parth of path so
$path
orgeneratePath(actualPath,user,id)
should return the same then hql would be something like outside of hql :In HQL:
outside of current function:
If
image
contained full image path including it's path the output offileName
in our substring above will be everything beyond actual path i.e. actual fileName uploaded.I actually fixed it using substring. I forgot that I can use parameters. I did something like:
I am surprised this didn't help substring(int beginIndex, int endIndex). But what about split(String regex, int limit). I think a little more information is needed of what you are trying to accomplish.