I had to change a JPA Inheritance strategy from SINGLE_TABLE to JOINED after moving my entities to an Maven module, in order for them to used from different applications.
The junit tests were OK when launched within Eclipse (Spring Boot, Spring Data JPA) but failed at Maven build (Mapping Exception).
#Entity
//#Inheritance(strategy = TABLE_PER_CLASS)
//#DiscriminatorColumn(name = "privilege_datarealm_type")
#Inheritance(strategy = JOINED)
public abstract class PrivilegeDataRealm<E extends SchemaElement>
extends Privilege<PrivilegeDataRealm<E>>
implements SchemaElement {
Does anyone have any clue of explanations for this issue ?
Related
We're starting a Spring Boot app with gradle bootRun which triggers the x.Application class which has the annotation #SpringBootApplication. After starting we can access REST services in the x package but can't access REST services in other packages. How can you configure the classpath accordingly?
Assuming your x package is something like com.example.mybootapp and your main Application.class is inside x package then you need to add this
#SpringBootApplication
#ComponentScan({"com.example.mybootapp","com.example.someother","one.more.pack"})
on your main Application.class method or Configuration file.
#SpringBootApplication itself consists of #Configuration #EnableAutoConfiguration #ComponentScan annotations, so #ComponentScan default the basePackge (i.e. packages to scan) to the package of the main Application.class and that is why Spring is unable to detect your other #Controlers which are outside of main package.
If you structure your code as suggested above (locating your application class in a root package), you can add #ComponentScan without any arguments. All of your application components (#Component, #Service, #Repository, #Controller etc.) will be automatically registered as Spring Beans.
Refer this document on how to structure your code.
I use STS 3.3.0 with roo 1.2.4. this one use GWT 2.5.0
When I database reverse engineer my database some fields are typed "BigDecimal", mainly amount on financial accounts. When I want to build using mvn gwt:run , I got a build failure due to the following error:
[ERROR] BigDecimalBox cannot be resolved to a type
After search in google I've found that GWT manage the BigDecimal since 2.1.
Any Clue?
Weird, there is no class with that name in the namespace you point (com.google.gwt.user.client.ui.ValueBox) in fact there is no BigDecimalBox in the gwt-2.5.1 library.
Implement it in your project and change imports to match the namespace you use for it.
public class BigDecimalBox extends ValueBox<BigDecimal> {
public BigDecimalBox() {
super(Document.get().createTextInputElement(), BigDecimalRenderer.instance(),
BigDecimalParser.instance());
}
}
I would like to use JPA annotations in ormlite. These annotations (like #Entity or #Id) belong to the javax.persistence package which is apparently not provided with ormlite. I could not get JPA annotations resolved, whereas ormlite specific annotations (like #DatabaseTable) are ok. Do I need to download a third party jar in order to get JPA annotations working in ormlite ?
I need to work with ormlite + JPA only.
When having a look at http://ormlite.com/javadoc/ormlite-core/index-all.html we can see that there are no JPA annotations documented nor available, although they are described in the user manual.
Thanks a lot in advance !!!
javax.persistence is available in a jar from the central maven repository (for example). It contains all annotations as well as all of the other JPA stuff that ORMLite ignores.
CMobileCom JPA is a new implementation of JPA specification for both Java JDBC and Android. It is light-weight, about 380K. You can add the following gradle dependencies:
Android:
dependencies {
implementation("com.cmobilecom:cmobilecom-jpa-android:${version}#aar") {
transitive = true
}
annotationProcessor "com.cmobilecom:cmobilecom-jpa-processor:$version"
}
Java JDBC:
dependencies {
implementation "com.cmobilecom:cmobilecom-jpa-jdbc:$version"
// annotation processor: generate static metamodel
compileOnly "com.cmobilecom:cmobilecom-jpa-processor:$version"
}
JPA annotations are supported, so you do not need to add another jar to resolve JPA annotations in your code.
See Developer Guide:
https://cmobilecom.com/docs/jpa/latest/devguide/index.html
Disclaimer: I am a developer of CMobileCom JPA.
I have trouble running Guice 3 within an OSGi container.
Following is a simple test I wrote to test if Guice work well with OSGi.
A simple guice module like:
public class Module extends AbstractModule {
#Override
protected void configure() {
bind(IInterface.class).to(IImplement.class);
}
}
The IInterface and IImplement are both very trivial.
The OSGi activator like this:
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
Injector inj = Guice.createInjector(new Module());
IInterface e = inj.getInstance(IInterface.class);
e.sayHello();
}
In Eclipse, I made a target contains all the Guice Jars, and to make guice resolve itself, I made two additional bundle for the aopalliance.jar and javax.injector.jar
However, this simple test fail to load the test bundle, gives me error message complaining cannot find a guice class cannot be found:
Exception in guicetest.Activator.start() of bundle guicetest
Caused by: java.lang.NoClassDefFoundError: com/google/inject/binder/AnnotatedBindingBuilder
at guicetest.guice.Module.configure(Module.java:11)
I hope I have made the problem clear. Can anyone show me how to resolve this problem?
Ah, after just posting the question I found the root of the problem. I didn't specify the com.google.inject.binder package, which the problematical class resides, in the test bundle's Import-Packages. Although the Module doesn't import directly that package, it looks it is still necessary to specify all the indirect dependent packages as well.
I am attempting to get EclipseLink JPA working inside the Spring dm Server OSGi environment.
Relevant frameworks and libraries downloaded from the Spring Enterprise Bundle Repository include:
dm Server 1.0.2.SR02
AspectJ Runtime 1.6.3
AspectJ Weaver 1.6.3
Spring Framework 2.5.6.A
Eclipse Persistence 1.1.0
Javax Persistence API 1.99.0
I followed the same structure as presented in the PetClinic-1.5.0 example for setting up EclipseLink JPA. Everything works until lazy-fetching is enabled (which requires proxied objects).
Once lazy-fetching is enabled, the following error suggests that load-time-weaving is not working correctly.
---- (truncated for readability)
Exception [EclipseLink-60] (Eclipse Persistence Services - 1.1.0.r3634): org.eclipse.persistence.exceptions.DescriptorExcep tion
Exception Description: The method [_persistence_setcustomer_vh] or [_persistence_getcustomer_vh] is not defined in the object [net.fractech.fds.backoffice.Job].
Internal Exception: java.lang.NoSuchMethodException: net.fractech.fds.backoffice.Job._persistence_getcu stomer_vh()
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[customer]
Descriptor: RelationalDescriptor(net.fractech.fds.backoffice.J ob --> [DatabaseTable(JOBS)])
This shows that the _persistence_getcustomer_vh() and _persistence_setcustomer_vh() methods were not automatically weaved into the Job domain object.
Questions
1.) How do I determine if load-time-weaving is actually working; moreover, how do I log which load time weaving agent and weaver was started? How do I pass switches to this weaver to have it output debugging information?
I assume I started load-time-weaving with <context:load-time-weaver aspectj-weaving="on" />
2.) Many searches have revealed that I do not need to pass the -javaagent parameter to the jvm when using dm Server. Is this correct?
3.) I have assured that my domain objects in another bundle have access to the eclipse persistence classes by asserting com.springsource.org.eclipse.persistence;version="[1.1.0,1.1.0]";import-scope:=application in my eclipselink bundle and including all application bundles within a PAR. Are there any other configurations needed to enable EclipseLink JPA in Spring dm Server?
I had similar problems. First try setting eclipselink.weaving.lazy=false, or eclipselink.weaving=false if that doesn't work. I had to set the latter.
If you would like to refer to the setup I am using to see if it applies to you, I have a post about it on my site.
It is better to use Equinox Waving Springwaver
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
...
<property name="loadTimeWeaver">
<bean class="org.eclipse.equinox.weaving.springweaver.EquinoxAspectsLoadTimeWeaver"/>
</property>
</bean>
You don't need to use -javaagent option then.
You can find working examples with JPA and EclipseLink here http://code.google.com/p/springdm-in-action/ (see Chapter 7).
I have tried to use EquinoxAspectsLoadTimeWeaver into JPa context (with EclipseLink) but it doen't transform the model classes if your EquinoxAspectsLoadTimeWeaver bean declaration is not done into the same bundle than Model bundle.
EquinoxAspectsLoadTimeWeaver transform class ONLY for the classes stored into the bundle wich declare EquinoxAspectsLoadTimeWeaver.
I have tried the sample http://code.google.com/p/springdm-in-action/ (see Chapter 7) (thank for this sample Lukasz). The declaration of EquinoxAspectsLoadTimeWeaver avoid having the error
Caused by: java.lang.IllegalStateException: Cannot apply class transformer without LoadTimeWeaver specified
But Model classes are not transformed (woven). Weaving into EclipseLink manage for instance lazy mode. For instance if you set into the sample model Contact lazy mode like this :
public class Contact {
...
#Column(name="last_name")
#Basic(fetch=FetchType.LAZY)
private String lastName;
you will notice that lazy loading is not applied because Model Contact class is not wowen.
Regards Angelo