Is there a way to apply the custom converter at global level for all classes.
I am trying to avoid to have every class specified in the mapping.xml file.
I want some thing like this
<mapping map-null="false">
<class-a>*</class-a>
<class-b>*</class-b>
</mapping>
I found the answer by myself
<configuration>
<map-null>false</map-null>
</configuration>
Related
I am fairly new to JPA and in my project the applciation server is Glassfish 3.1.2
.So when i encountered persitence.xml in my project ,I have gone through http://en.wikibooks.org/wiki/Java_Persistence/Runtime to get basic idea of how it is used in JavaSE and JavaEE.
However i came across few properties that are configured via ${}.
<jta-data-source>${dataSource}</jta-data-source>
<property name="javax.persistence.jdbc.user" value="${testDBUser}" />
So i am confused where these variables (dataSource,testDBUser..etc) are defined. And so i have gone through this
http://tomee.apache.org/configuring-persistenceunits-in-tests.html and
http://forcedotcom.github.io/java-sdk/connection-url.
I understood that these are either system varibales and environmental variables / initial context variables.
However i do not know where they are configured/declared ,i searched my entire project for these variables but of no luck.
Are these variables are configured during the start-up of the application server / are they declared in any *.xml of the application server.
Can you please brief where these are declared?
It is usually are declared in .properties file. Mainly, it can be named like database.properties. But it is not enough to make it work. You need somehow to map it. So, Spring takes a role and offer a nice way to make it : use PropertyPlaceholderConfigurer and syntax is something like this:
<property name="location">
<value>HERE DECLARE YOUR PROPERTY FILE</value>
<value>HERE DECLARE YOUR PROPERTY FILE</value>
...
</property>
But the best way is to declare it in your server.xml :)
How do I exclude a protected method from javadoc?
I need to document some but not all protected methods.
Thanks
You can exclude all protected methods with the command line option "-protected", but I just re-read your question more closely and realize this is probably not what you are looking for.
You can't do this with straight Javadoc but, depending on what other javadoc facilities you need, and how it is you are generating your javadoc, you could consider switching to Doclava. Doclava is a doclet (think: plug-in) for javadoc and it does recognise the #hide tag.
The HTML output is much prettier too.
Unfortunately it doesn't recognise large swathes of javadoc command line options, so it may not be suitable.
https://code.google.com/p/doclava/
If you are using the maven plugin, you can use the show tag into the configuration tag with value public as shown below. In that case, only public members of classes will be displayed into javadoc.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.1</version>
<configuration>
<show>public</show>
<doctitle>My company API</doctitle>
<subpackages>my.company.package.api</subpackages>
</configuration>
</plugin>
I have FunctionImport in one edmx1 file and I want to set the ReturnType to object that is located in other edmx2 file.
for example, I have edmx1 file with following FunctionImport and t_Page object defined in edmx1 file
edmx1
<FunctionImport Name="CopySite" EntitySet="t_Page" ReturnType="Collection(Entities.t_Page)">
<Parameter Name="assemblyId" Mode="In" Type="Int32" />
<Parameter Name="projectId" Mode="In" Type="Int32" />
</FunctionImport>
Now, I want to change the ReturnType, so it will return c_Page(declared in edxm2) instead of t_Page. If I just change t_Page to c_Page in edmx1 I get error that c_Page is not defined in edmx
<FunctionImport Name="CopySite" EntitySet="c_Page" ReturnType="Collection(Entities.c_Page)">
<Parameter Name="assemblyId" Mode="In" Type="Int32" />
<Parameter Name="projectId" Mode="In" Type="Int32" />
</FunctionImport>
How I can do this?
UPDATED
The reason why I need this is:
I have several DBs with different tables except 5 of them that has same scheme but different names in each DB(e.g. c_Page,d_Page,e_Page...). It has to be with different names! Now, when I create edmx for each DB I don't want to have hundreds of "same" classes, because they all have the same scheme but different names, so I want map the same class to all those tables
Maybe I need Entity Framework 4 “Code-First”? But in this way I need to create classes manually, right?
Can you suggest me how I can do this?
This is normally not possible. You can use only types defined within same EDMX file.
The only situation when this can be possible is described in this article where you are able to include one CSDL file into another. This would allow you defining entity in one CSDL file and include that CSDL file to second EDMX where you will be able to define FunctionImport and hopefully also used that entity (I didn't tested it). But it has some consequences:
Only CSDL files can be divided this way
You still need single shared MSL and SSDL file for both CSDL files
You cannot use EDMX (container for these files) any more
You cannot use designer and related automated tools and wizards
Edit:
So based on your edit you must have entities defined in every EDMX - there is no way how to avoid that. If you ensure that entities will be exactly same in every EDMX (including: names, keys, property names, relations) you can modify your T4 templates used to generate classes so that only one template generate them. After that you would need to ensure that ObjectContext derived classes generated by templates use correct classes in their exposed sets. It is all about some modifications in T4 templates.
I'm generating java code based on various WSDL's. We have a different WSDL for every new version of the WebService that we release, each with its own namespace.
The thing is that normally the changes are minimal from one release to another, but I want to keep classes divided by namespace.
Is there a way to configure JAXB so that the auto generated classes implement a single interface/extend a single class, so I can refer to either of them without changing my code?
Dummy example:
WebService method: listScripts(ResultSize size);
Auto generated classes:
com.test.ws1.ResultSize
com.test.ws2.ResultSize
Both classes are exactly the same. Is there a way to arrange them in a class hierarchy so my code is isolated from changes in version numbers? i.e. a com.test.ResultSize interface implemented by both classes?
XJC has an extension for this purpose
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.0">
<xs:annotation>
<xs:appinfo>
<jaxb:globalBindings>
<xjc:superClass name="com.mycompany.xml.UserRootObject"/>
</jaxb:globalBindings>
</xs:appinfo>
</xs:annotation>
.
.
.
</xs:schema>
For more information see:
http://jaxb.java.net/nonav/2.0.2/docs/vendorCustomizations.html
The schema annotations can also be supplied via an external bindings file. For an example see:
How do you customize how JAXB generates plural method names?
It turned out that I can use a plugin provided in the JAXB2 Basics package:
Inheritance plugin
With this plugin I can specify different super classes for my generated ones, although I couldn't make the auto generated enums to implement a given interface.
To use it in Maven it was a pain (I'm generating classes from a WSDL, not using JAXB directly), so I switched to an external Ant task as specified in this blog
I want to use JSR 303 Bean validation on my classes. My problem is that these classes are generated from schema. I am using the jaxb annotate plugin on my bindings file and was able to define simple validation annotations like #NotNull. My problem comes when I have to define multiple annotations of same type for different groups. javax.validation offers a solution for this using annotations like #Size.List{#Size...). How can I use jaxb-annotate and annox plugin to define annotations like those.
You can define nested annotations with Annox, it's no problem. In your case it will be something like:
In *.xjb file:
<annox:annotate>
<annox:annotate annox:class="javax.validation.constraints.Size$List">
<annox:annotate annox:field="value">
<annox:annotate annox:class="javax.validation.constraints.Size" .../>
</annox:annotate>
</annox:annotate>
</annox:annotate>
In schema:
<annox:annotate>
<c:Size$List xmlns:c="http://annox.dev.java.net/javax.validation.constraints">
<c:value>
<c:Size ... />
</c:value>
</c:Size$List>
</annox:annotate>
I haven't tested it, so the syntax may be a bit different.
See the Annox user guide an the Annotate plugin docs.