Darren Carter

Ranch Hand
+ Follow
since Jul 08, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Darren Carter

Ok so I have had some playing around..

I now have configured the checkbox to



This works however why are are all the check boxes pre-ticked?

11 years ago
Hi, Im really stuck and was hoping someone could help me I am trying to bind a List to the checkboxes tag, but im getting the following error.



Here is my Pojo .



Here is my controller



Here is my JSP



As you can see the products in menusection is a ArrayList so what else am I missing? Have I got my checkboxes binding path and items wrong?

Really appreciate some help on this :-)


11 years ago
Hi All,

After working on middleware for a while I started to get back into spring mvc.

I have simple domain model
1) A site which has a SiteMenu.
1) SiteMenu conrtains a list of MenuSections
2) MenuSections contains a List of products

My controller returns the SiteMenu to the view based on a previous selected Site.
My view then displays the SiteSections and the associated products.

Here is my view




My controller



However when I submit the form, selecting two products from one MenuSection, my controller shows the binding is incorrect in object SiteMenu.

For example in SiteMenu I get a list of MenuSections that has two values values. I would expect MenuSections to have a list of one value with two products.

Can any spot what I am doing wrong please.?



11 years ago
Hi Everyone,

I really hope someone could help as I been struggling with an issue with hibernate and a spring mvc app. I must be doing something silly and was hoping someone could help.

I have the following relationships


1) SiteMenu has many MenuSection
2) SiteMenu has one Site
2) MenuSection has Many Products


I simply trying to retrieve a SiteMenu object which contains all the MenuSecions and associated Products. However when I add the products to my hibernate mapping (MenuSection.hbm), I receive duplicate MenuSection objects in my query. Removing the products association returns the correct number of MenuSections.

Here are the Hibernate Mappings



Here is my Criteria query



Why is it if I introduce products it duplicates the records returned? Can some please help as I am not sure what to do?

Best Regards





Hi Everyone,

I have a XML docment in which I need to unmarshall into a java object using jaxb. I am a little unclear of how I should map the xml annotations in my pojo and was hoping someone could advise?

my XML document is



Pojo



Can any one tell me how I would map this using annotations? so for example card_name should be mapped to cardName.

Thanks
D.

Hi All,

I have a new requirement where I need to connect to a third party XML PRC interface.

I have not done this in spring before and was hoping if someone could point me in the right direction of what I should be using.

The Api endpoint takes this example request:

Function: api.tcrc_checkCard

<?xml version="1.0"?>
<methodCall>
<methodName>api.tcrc_checkCard</methodName>
<params>
<param><value><string>yourUsername</string></value></param>
<param><value><string>yourPassword</string></value></param>
<param><value><string>90070299999999</string></value></param>
</params>
</methodCall>

And sends a response such as

<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<params>
<param><value>
<struct>
<member><name>card_name</name><value><string>Test</string></value></member>
<member><name>scheme_max_award</name><value><int>10000</int></value></member>
<member><name>card_balance</name><value><int>0</int></value></member>
<member><name>error_code</name><value><int>0</int></value></member>
<member><name>error_description</name><value><string>success</string></value></member>
</struct></value>
</param>
</params>
</methodResponse>

Ive been reading about the Springs Httpinvoker but Im a little confused on how this would be configured? Am I on the right path with this?

Thanks



11 years ago
Hi,

The version of hibernate is 3.6.10.

To provide further information on this issue. The out of memory was due to hibernate returning hundreds of thousands of rows for my sky subscription list. I checked this by doing a lazy load on my List and checking the list size.

In the H2 database I have only one user account, with only one associated sky subscription.

I changed the sky table to include an auto increment id (which is now pk) and have a unique key of sky_viewing_card_id.

Findings

When my "one to many" mapping in user_account looks like this, it returns hundreds of thousands of skysubscriptions:



However, when I change the list-index column to active, it returns the one association -Great!.

So what I want to understand is
1) why does hibernate do this when it indexs my unique key? <list-index column="sky_viewing_card_id"/>
2) when I change to <list-index column="active"/>, it returns a list count of 2 entries - One is my skysubscription and the other is null.. what does it return a null record?

Thanks for the help, and im wondering if using HQL would be a better option?
Hi Eveyone,

really need some help with this.

I am receiving the memory error while trying to retrieve a record from the database in my spring rest api. The object am retrieving has a one to many relationship.

The Stack trace



The Hibernate mapping


The DAO



I am running this as an integration test via spring test. Ive checked my eclipse.ini and have plenty or perm gem space i.e -XX:MaxPermSize=2048m

Can anyone help?

Regards
Darren
Hi Dieter,

Thank you for the advise and yes merge works. I now underatand that the mege will update the managed object from the unmanged object.

Thanks
Hi,

I have a problem with hibernate, and im not understanding what is wrong.

I get the following error



So from what I understand hibernate is complaining because I am trying to save a different object of the same id, which has already been saved?..

My XML Mappings – One to Many




My DAO



So what I don’t understand is why hibernate thinks I have already saved the SocialAccount with that id already?

Can someone please help?

Hi,

I was hoping someone could help.

I have developed a secure rest API in spring that receives json, and then uses JSR303 bean validation using @RequestBody @Validated etc.. This all works fine.

However it has now been decided that the whole json string to be sent to my REST API, needs to be encrypted in AES.

So within a custom spring security filter I have pulled the encrypted string from the request, decrypted it to Json, do authentication etc...

I basically now need to put the json into the request, so that my controllers @RequestBody Annotations can continue to do their magic.

How do I put the JSON into the request within my filter? Also is there is a better approach and how does everyone encrypt their json? Was wondering if its easier to encrypt each filed with field?

Snippet of Filter



Regards
D.



11 years ago
Hi everyone,

I hope someone could help me.

Im developing a security module where I would like to apply authentication mechanisms to separate REST urls.

My issue is that my custom filter is applied to all URLs that I enter. I thought that if I changed the intercept URL pattern then the filter would not need to be applied? can anyone help me understand this?

Here’s my Config



So if I access /database/register/user - The customRestFilter is applied

but if I access /database/login - The customRestFilter is also applied - I thought this would not be the case???

Can anyone help me understand this please??



11 years ago
Hi Everyone,

With Thanks to Rossen Stoyanchev I have this working.

In short the problem is to do with standloneSetup with does not load spring configuration.

One option is to create a LocalValidatorFactoryBean configured with a SpringConstraintValidatorFactory and plug it into the standaloneSetup builder.

However I decided to migrate from spring-test-mvc to spring-test in 3.2.

All that was required was to annotate my test class with @WebAppConfiguration, load in my spring configuration files with @ContextConfiguration and then @Autowired WebApplicationContext

Example




I can now @Autowire services in my custom jsr annotation validator.

Hope this helps others

Regards
Darren C.


Hi Eveyone,

I have posted this in the Spring forums but have not had a reply. Can anyone help with this please..?

I have an issue with autowiring inside a custom constraint validator when running an integration test using spring-test-mvc. The service I require is null.

However when I run the web app, its is auotwired correctly.

Custom Constraint Validator (Booking Service is null!)



Annotation


Service


Unit Test



Config



Controller


Hi Winston,

Thank you very much! - This is very imfomative and has put me back on the right track.

Its nice to know that there is help out there!

12 years ago