Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parameterType for Complex Type #93

Open
nirodg opened this issue Mar 1, 2017 · 4 comments
Open

parameterType for Complex Type #93

nirodg opened this issue Mar 1, 2017 · 4 comments

Comments

@nirodg
Copy link

nirodg commented Mar 1, 2017

It is supported yet?

Let's say you have <property name="parameterNames" value="id, phone, contact.Name"/>. I'm interested on being able to fetch the value contact.Name

@chengfang
Copy link
Contributor

Custom POJO types are not supported in batch property injection. However, you can inject into fields of type java.util.List with a comma-separated values, or java.util.Map with a comma-separated key-value pairs.

@nirodg
Copy link
Author

nirodg commented Mar 1, 2017

My problem is that I have a @OneToMany so at one point I have to do phone.setContact(contact);
but on the table contact's column name is contact_id.

So my approach is:

class PhonePojo{
	String id;
	String phone;
	String contactId;
}

By the way, thanks @chengfang for the fast reply and I think the issue can be closed 👍

@nirodg nirodg closed this as completed Mar 1, 2017
@nirodg
Copy link
Author

nirodg commented Mar 2, 2017

Hi @chengfang , sorry for reopening this issue but do you think that this could be implemented ? If so I'd like to have a try implementing this functionality

@nirodg nirodg reopened this Mar 2, 2017
@chengfang
Copy link
Contributor

chengfang commented Mar 2, 2017

JBeret uses CDI to perform the property @Inject. Without knowing the target POJO type, it's hard to do it in JBeret. However, it will be easier to do it in your application. For instance, you can inject the value as a JSON string, and deserialize the injected JSON string into the target object with library like Jackson.

<property name="foo" value='
{
"id": 123,
"phone": "123-456-7890",
"contacts": "xxx"
}
'/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants