I'm trying to use the Play framework (Java) to simply read some data from a few Oracle tables, probably even use a few complex queries later on. I'm following a tutorial but I'm having some issues retrieving the data.
My Model class look like this:
package models;
import java.util.ArrayList;
import java.util.List;
import play.libs.F;
import javax.persistence.*;
import com.avaje.ebean.*;
import play.db.ebean.*;
#Entity
#Table(name="TABLESPACE.CAT_BONDS")
public class Cat_Bond extends Model {
#Id
public String symbol;
public String database;
public String tickType;
public String assetClass;
public String sourcePlatform;
public String sourceExchange;
public static Finder<String, Cat_Bond> find = new Finder<String, Cat_Bond>(String.class,Cat_Bond.class);
public Cat_Bond(){}
public Cat_Bond(String symbol, String database, String tickType, String assetClass,
String sourcePlatform, String sourceExchange) {
this.symbol = symbol;
this.database = database;
this.tickType = tickType;
this.assetClass = assetClass;
this.sourcePlatform = sourcePlatform;
this.sourceExchange = sourceExchange;
}
/*
* retrieve all rows from the 'cat_bonds' table
*/
public static List<Cat_Bond> findAll(){
//return new ArrayList<Cat_Bond>(cat_bond);
return find.all();
}
/*
* Find by EAN
*/
public static Cat_Bond findByEan(String symbol){
return find.where().eq("symbol", symbol).findUnique();
}
}
My controller class:
package controllers;
import java.util.List;
import views.html.*;
import models.Cat_Bond;
import play.data.Form;
import play.mvc.*;
public class Cat_Bonds extends Controller {
private static final Form<Cat_Bond> cat_bondForm = Form.form(Cat_Bond.class);
public static Result list(){
List<Cat_Bond> cat_bond = Cat_Bond.findAll();
return ok(list.render(cat_bond));
}
And the application.conf entry looks like:
#Oracle
db.default.driver=oracle.jdbc.OracleDriver
db.default.url="jdbc:oracle:thin:#server.uk.net.intra:port/ALIAS"
db.default.user=user
db.default.password=pass
# Evolutions
# ~~~~~
# You can disable evolutions if needed
evolutionplugin=disabled
Problem is when the call to list is made in the controller then to findAll() in the model I get the error:
**[PersistenceException: Query threw SQLException:ORA-00904: "T0"."SOURCE_EXCHANGE": invalid identifier Bind values:[] Query was: select t0.symbol c0, t0.database c1, t0.tick_type c2, t0.asset_class c3, t0.source_platform c4, t0.source_exchange c5 from TABLESPACE.CAT_BONDS t0 ]**
#Column(name="xx")
Was required above each variable defined in the model class that was to be mapped to the table column.
You can use
clean
compile
~run
If it doesn't work properly, you can use #EntityConcurrencyMode(ConcurrencyMode.NONE) within your model class.
Related
I have a array list of a Model class which has multiple String type variables.
This Array list values is populated from JDBC template result set.
Now I want to iterate this Array List and update some of these model element based upon some conditions.
My Model Class:
import lombok.Getter;
import lombok.Setter;
#Getter
#Setter
public class WADataModel {
public String STATUS;
public String AUTO_DATE;
public String RECORD_TYPE;
public String VENDOR_NAME;
public String CREATED_DATE;
public String ACTION_CODE;
public String CITY;
public String GROUP_NUMBER;
public String GROUP_POLICY_NUMBER;
public String SUBGROUP_NUMBER;
public String SUBGROUP_POLICY_NUMBER;
public String SYSTEM;
public String PLAN_NUMBER;
}
My DAO Class:
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Component;
#Component
public class PlanCrosswalks {
#Autowired
#Qualifier("nemisNamedJdbcTemplate")
private NamedParameterJdbcTemplate nemisJdbcTemplate;
#Autowired
private FetchDatafFromProp fetchDatafFromProp;
#Value("${query.state}")
private String queryState;
public List<WADataModel> doWACrosswalk(List<WADataModel> claimDataList) throws ApplicationExceptions{
RowMapper<WACrosswalkModel> rowMapper = new BeanPropertyRowMapper<>(WACrosswalkModel.class);
List<WACrosswalkModel> statusResult = new ArrayList<>();
Map<String,String> crosswalkQueryMap = new HashMap<>();
Map<String,String> paramMap = new HashMap<>();
crosswalkQueryMap = fetchDatafFromProp.getDataForGeneration();
statusResult = nemisJdbcTemplate.query(crosswalkQueryMap.get(queryState+ Constants.UNDERSCORE + Constants.FETCH_SUB_GROUP_POLICY),paramMap,rowMapper);
for(WADataModel model : claimDataList)
//Here I want to update ClaimDataList elements like SUBGROUP_POLICY_NUMBER,GROUP_POLICY_NUMBER based upon some conditions by iterating whole List.
return claimDataList;
}
}
I want to iterate "claimDataList" and check whether plan_number is null and update subGroupPolicyNumber accordingly based upon the value of plan_number.
I can iterate List of model but don't know how to update the values in List of model.
Please help me to update the values in "claimDataList"
Write a method to update one model.
Then you can iterate over the list of models, filter them and call this method for the resuming models.
I would prefer a stream:
claimDataList.stream()
.filter(model -> model.PLAN_NUMBER == null)
.forEach(this::planNumberNull);
private void planNumberNull(WADataModel model) {
model.SUBGROUP_POLICY_NUMBER = ...
}
for(WADataModel model : claimDataList){
if(model.PLAN_NUMBER==null){
model.SUBGROUP_POLICY_NUMBER = <>
}
}
If I have understood, you want to check that the value 'PLAN_NUMBER' is not null, and then fill the variable 'SUBGRUOUP_POLICY_NUMBER'.
You can do this with lambdas (since j8), which is optimal.
claimDataList.stream()
.filter(x -> x.getPLAN_NUMBER() != null)
.forEach(y -> y.setSUBGROUP_POLICY_NUMBER(y.getPLAN_NUMBER()));
I am new to Spring Jpa and Hibernate. I am trying to fetch data using a custom function from an Oracle db. I could define an entity along with its related service, implementation and repository. In addition, I created a new custom Oracle dialect by using registerFunction as you will see below.
So I have two questions:
1) In my Oracle db, the function sits under a different schema. Do I need to specify its schema? If so how? Or will hibernate find it automatically?
I will be asking my second question at the end of this post after providing my full stacktrace...
Here is my full stack trace:
MyOracle10gDialect
package blog;
import org.hibernate.dialect.Oracle10gDialect;
import org.hibernate.dialect.function.StandardSQLFunction;
public class MyOracle10gDialect extends Oracle10gDialect {
public MyOracle10gDialect() {
super();
registerFunction("my_function", new StandardSQLFunction("my_function"));
}
}
application.properties
...
spring.jpa.database-platform=blog.MyOracle10gDialect
...
Entity:
package blog.models;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table(name = "item", schema = "WOS_SOURCE")
public class WosItem {
#Id
#Column(nullable = false)
private String UT;
#Column(nullable = false)
private String TI;
public String getUT() {
return UT;
}
public void setUT(String UT) {
this.UT = UT;
}
public String getTI() {
return TI;
}
public void setTI(String TI) {
this.TI = TI;
}
public WosItem(String UT, String TI) {
this.UT = UT;
this.TI = TI;
}
public WosItem() { }
#Override
public String toString() {
return "WosItem{" +
"UT='" + UT + '\'' +
", TI='" + TI + '\'' +
'}';
}
}
Service:
package blog.services;
import blog.models.WosItem;
import org.springframework.stereotype.Service;
import java.util.List;
#Service
public interface WosItemService {
List<WosItem> findAll();
WosItem findById(String id);
String find_ut(Long ut_seq);
}
Implementation:
package blog.services;
import blog.models.WosItem;
import blog.repositories.WosItemRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
#Service
public class WosItemServiceJpaImpl implements WosItemService {
#Autowired
private WosItemRepository wosItemRepository;
#Override
public List<WosItem> findAll() {
return this.wosItemRepository.findAll();
}
#Override
public WosItem findById(String id) {
return this.wosItemRepository.findOne(id);
}
#Override
public String find_ut(Long ut_seq) {
return this.wosItemRepository.find_ut();
}
}
Repository:
package blog.repositories;
import blog.models.WosItem;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
#Repository
public interface WosItemRepository extends JpaRepository<WosItem, String> {
#Query("SELECT function('my_function', input) FROM WosItem wos");
String find_ut();
}
So in my Oracle db I can use this function as shown below:
select other_schema.my_function(aa.input) from my_schema.TABLE aa;
For ex. say aa.input is 332708100009 then it returns 000332708100009
As for my second question:
2) How can I carry out this process in jpa? I am aware that my repository is not correct at all. I get an error like "Annotations are not allowed here". I could not find a way to remedy this.
Thanks in advance.
EDIT ON THROWN EXCEPTION:
Caused by: java.lang.IllegalStateException: No data type for node: org.hibernate.hql.internal.ast.tree.MethodNode
\-[METHOD_CALL] MethodNode: 'function (my_function)'
+-[METHOD_NAME] IdentNode: 'my_function' {originalText=my_function}
\-[EXPR_LIST] SqlNode: 'exprList'
\-[NAMED_PARAM] ParameterNode: '?' {name=ut_seq, expectedType=null}
Unfortunately if you want to use the JPA 2.1 feature of the custom function call in your Select statement then you will need to perform some additional actions before you can use it.
When you use it in your where statement then it works without any additional actions, but as i wanted to use it for one of my projects inside the select just as you did then you would need to:
1) Extend the hibernate dialect and register your function(s):
package com.mypkg.dialect;
import org.hibernate.dialect.Oracle10gDialect;
import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.type.StringType;
public class CustomOracle10gDialect extends Oracle10gDialect {
public CustomOracle10gDialect() {
super();
registerFunction("my_function"
, new StandardSQLFunction("my_function", new StringType()));
}
}
2) Edit your hibernate.dialect property of your session factory to point to that custom implementation:
<property name="hibernate.dialect" value="com.mypkg.dialect.CustomOracle10gDialect"/>
Update
If the function needs to be called from a certain schema then this would be suggested:
registerFunction("my_function"
, new StandardSQLFunction("schema.my_function", new StringType()));
Further reading -> native function calls
The following is a simplification of a more complicated setup. I describe this simple case to show the effect.
I start Spring Boot and call a method. In this method all the contents of a MySQL database table is read via
Iterable<myPojo> myPojos = myPojoRepository.findAll();
Afterwards I leave this method.
After finishing this method I get the message
Started Application in 70.893 seconds (JVM running for 72.899)
So Spring Boot is idling afterwards.
But still the memory is not released.
How can I avoid that the JVM Heap is not released after the application is idling?
This is the result of VisualJM after the application is idling:
char[] 1.080.623.712 (21.0%) 24.040.578 (23.4%)
byte[] 1.034.070.352 (20.1%) 17.280.824 (16.8%)
java.lang.String 768.935.872 (14.9%) 24.029.246 (23.4%)
java.lang.Object[] 556.181.104 (10.8%) 5.320.276 (5.1%)
org.hibernate.engine.internal.MutableEntityEntry
231.287.232 (4.5%) 2.628.264 (2.5%)
org.hibernate.engine.spi.EntityKey
224.752.040 (4.3%) 5.618.801 (5.4%)
byte[][] 212.407.904 (4.1%) 3.318.832 (3.2%)
hello.web.model.MyPojo 185.852.968 (3.6%) 3.318.803 (3.2%)
java.util.HashMap$Node 145.238.976 (2.8%) 3.025.812 (2.9%)
com.mysql.jdbc.ByteArrayRow 132.752.120 (2.5%) 3.318.803 (3.2%)
org.hibernate.engine.internal.EntityEntryContext$ManagedEntityImpl
126.156.720 (2.4%) 2.628.265 (2.5%)
hello.web.model.MyPojoCompoundKey
120.376.680 (2.3%) 3.009.417 (2.9%)
java.util.HashMap$Node[] 108.307.328 (2.1%) 16.558 (0.0%)
java.lang.Float 79.651.320 (1.5%) 3.318.805 (3.2%)
int[] 41.885.056 (0.8%) 54.511 (0.0%)
java.util.LinkedHashMap$Entry 15.519.616 (0.3%) 242.494 (0.2%)
java.io.File 11.323.392 (0.2%) 235.904 (0.2%)
org.springframework.boot.devtools.filewatch.FileSnapshot
10.550.400 (0.2%) 219.800 (0.2%)
java.lang.String[] 8.018.808 (0.1%) 52.031 (0.0%)
java.lang.reflect.Method 6.015.040 (0.1%) 37.594 (0.0%)
java.io.File[] 2.283.528 (0.0%) 16.746 (0.0%)
My effective-pom.xml shows that hibernate 5.0.9.Final is used.
The table my_pojo contains 3.3 million entries.
MyPojoRepository:
package hello.web.model;
import com.querydsl.core.types.Predicate;
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface MyPojoRepository
extends PagingAndSortingRepository<MyPojo, Long>,
QueryDslPredicateExecutor<MyPojo> {
List<MyPojo> findAll(Predicate predicate);
}
MyPojo:
package hello.web.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import org.apache.commons.beanutils.BeanComparator;
import org.apache.commons.collections.comparators.ComparatorChain;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
#Data
#Entity
#Builder
#AllArgsConstructor
#IdClass(MyPojoCompoundKey.class)
public class MyPojo implements Serializable, Comparable<MyPojo> {
public MyPojo() { }
#Id
private String myId1;
#Id
private String myId2;
#Id
private String myId3;
private Float myId4;
private String myId5;
#Override
public int compareTo(MyPojo o) {
return this.getMyId3().compareTo(o.getMyId3());
}
protected boolean canEqual(Object other) {
return other instanceof MyPojo;
}
public static void sortByMyId1MyId3(List<MyPojo> myPojos) {
ComparatorChain chain = new ComparatorChain(Arrays.asList(
new BeanComparator("myId1"),
new BeanComparator("myId3")
));
Collections.sort(myPojos, chain);
}
}
myId1-3 and myId5 have a length of 10 characters in avarage.
So again:
How can I avoid that the JVM Heap is not released after the application is idling?
I have a strange problem with mapping MongoDB objects in document to Java hash maps.
If I store an object with HashMap like this ("Message-Id" => "something") to some collection and get it from db again, the result object will have HashMap with this ("Message.Id" => "something").
I using Spring Data MongoDB in Spring Boot application.
Unit test:
package com.mailor.app.data.mapping.bugs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.springframework.data.mongodb.core.query.Criteria.where;
import static org.springframework.data.mongodb.core.query.Query.query;
import java.util.HashMap;
import java.util.Optional;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.google.common.collect.Maps;
import com.mailor.app.data.DataConfig;
import com.mailor.app.data.TestDataConfig;
import com.mailor.app.data.constants.HeaderParams;
import com.mailor.app.data.mapping.entity.MessageIdTestEntity;
/**
* #author jakob
*
*/
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration(classes = { DataConfig.class, TestDataConfig.class })
public class MessageIdDotDashTest {
#Autowired
private MongoTemplate template;
#Test
public void messageIdDotOrDashTest() {
//HeaderParams.MESSAGE_ID = Message-Id
dotOrDashInKeyTest(HeaderParams.MESSAGE_ID);
}
#Test
public void contentTypeDotOrDashTest() {
dotOrDashInKeyTest("Content-Type");
}
#Test
public void somethingDotOrDashTest() {
dotOrDashInKeyTest("Something-with-dashes");
}
#Test
public void hashMapSetOnKeyWithDashTest() {
HashMap<String, String> testMap = Maps.newHashMap();
testMap.put(HeaderParams.MESSAGE_ID, "something");
assertEquals("something", testMap.get(HeaderParams.MESSAGE_ID));
}
private void dotOrDashInKeyTest(String key) {
String messageId = "some kind of message id";
MessageIdTestEntity testEntity = new MessageIdTestEntity();
testEntity.getHeaders().put(key, messageId);
template.save(testEntity);
Optional<MessageIdTestEntity> testEntityFromDB = Optional.ofNullable(template.findOne(query(where("code").is(testEntity.getCode())), MessageIdTestEntity.class));
assertTrue(testEntityFromDB.isPresent());
assertNotNull(testEntityFromDB.get().getHeaders().get(key)); // THIS FAILING, header key is Message.Id not Message-Id
assertEquals(messageId, testEntityFromDB.get().getHeaders().get(key));
}
}
Test object:
package com.mailor.app.data.mapping.entity;
import java.util.HashMap;
import java.util.UUID;
import com.google.common.collect.Maps;
/**
* #author jakob
*
*/
public class MessageIdTestEntity {
private String code = UUID.randomUUID().toString();
private HashMap<String, String> headers = Maps.newHashMap();
/**
* #return the code
*/
public String getCode() {
return code;
}
/**
* #return the headers
*/
public HashMap<String, String> getHeaders() {
return headers;
}
/**
* #param headers
* the headers to set
*/
public void setHeaders(HashMap<String, String> headers) {
this.headers = headers;
}
}
Fixed by using
((MappingMongoConverter)
mongoTemplate.getConverter()).setMapKeyDotReplacement("#dot#");
Explanation
We are using standart notation for dot replacement in mongo db object keys (dots are forbidden there), which using a dash (-) as replacement for dot (.).
((MappingMongoConverter)
mongoTemplate.getConverter()).setMapKeyDotReplacement("-");
But, if you have a object key with dash now, MongoDB mapper replace dash with dot, because he dont know whether you saving key with dash or dot previously.
For this reason, we must use unique dot key replacement like #dot# or something rare, something you never use in object key names.
public static UserDetail UserDetail.findUserDetail(Long id) {
if (id == null) return null;
return entityManager().find(UserDetail.class, id);
}
We are using spring Roo. Above is Roo generated finder method. Partial stack trace is as follows:
Caused by: org.hibernate.WrongClassException: Object with id: 1501237 was not of the specified subclass: com.***.***.user.UserDetail (Discriminator: FacebookUserDetail)
Has anyone come across this exception?
EDIT
This question and following questions are related to same issue.
Java class file truncated
I have two projects. My one project (say project2) depends on another project(project2). Both projects are maven project and project1 is listed in dependancies of project2. When I compile project2, all the class files from project1 should be copied to project2 (I imagine). But, I see that the file size of one of the class files in project1 is different than file size of class file for the same class in project2. If I decompile the files I get following results.
Decompiled FacebookUserDetail.class from project1:
package com.***.domain.user.external;
import com.***.domain.user.UserDetailType;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.TypedQuery;
import org.aspectj.lang.JoinPoint;
import org.aspectj.runtime.internal.CFlowCounter;
import org.aspectj.runtime.reflect.Factory;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.aspectj.AbstractDependencyInjectionAspect;
import org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect;
import org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl;
#Configurable
#Entity
public class FacebookUserDetail extends ExternalUserDetail
{
public FacebookUserDetail()
{
JoinPoint localJoinPoint = Factory.makeJP(ajc$tjp_1, this, this); if ((!AnnotationBeanConfigurerAspect.ajc$if$bb0((Configurable)getClass().getAnnotation(Configurable.class))) && (AbstractDependencyInjectionAspect.ajc$if$6f1(localJoinPoint))) AnnotationBeanConfigurerAspect.aspectOf().ajc$afterReturning$org_springframework_beans_factory_aspectj_AbstractDependencyInjectionAspect$2$1ea6722c(this);
}
public static FacebookUserDetail findFacebookUserDetailByFacebookId(String facebookId)
{
String str = facebookId; JoinPoint localJoinPoint = Factory.makeJP(ajc$tjp_0, null, null, str); if ((AnnotationDrivenStaticEntityMockingControl.ajc$cflowCounter$1.isValid()) && (AnnotationDrivenStaticEntityMockingControl.hasAspect())) return (FacebookUserDetail)findFacebookUserDetailByFacebookId_aroundBody1$advice(str, localJoinPoint, AnnotationDrivenStaticEntityMockingControl.aspectOf(), null, ajc$tjp_0, localJoinPoint); return findFacebookUserDetailByFacebookId_aroundBody0(str, localJoinPoint);
}
public UserDetailType getExternalUserDetailType()
{
return UserDetailType.FACEBOOK;
}
static
{
ajc$preClinit(); }
public static long countFacebookUserDetails() { return FacebookUserDetail_Roo_Entity.ajc$interMethod$com_nim_domain_user_external_FacebookUserDetail_Roo_Entity$com_nim_domain_user_external_FacebookUserDetail$countFacebookUserDetails(); }
public static List<FacebookUserDetail> findAllFacebookUserDetails() { return FacebookUserDetail_Roo_Entity.ajc$interMethod$com_nim_domain_user_external_FacebookUserDetail_Roo_Entity$com_nim_domain_user_external_FacebookUserDetail$findAllFacebookUserDetails(); }
public static FacebookUserDetail findFacebookUserDetail(Long paramLong) { return FacebookUserDetail_Roo_Entity.ajc$interMethod$com_nim_domain_user_external_FacebookUserDetail_Roo_Entity$com_nim_domain_user_external_FacebookUserDetail$findFacebookUserDetail(paramLong); }
public static List<FacebookUserDetail> findFacebookUserDetailEntries(int paramInt1, int paramInt2) { return FacebookUserDetail_Roo_Entity.ajc$interMethod$com_nim_domain_user_external_FacebookUserDetail_Roo_Entity$com_nim_domain_user_external_FacebookUserDetail$findFacebookUserDetailEntries(paramInt1, paramInt2); }
public static TypedQuery<FacebookUserDetail> findFacebookUserDetailsByUserIdEquals(String paramString) { return FacebookUserDetail_Roo_Finder.ajc$interMethod$com_nim_domain_user_external_FacebookUserDetail_Roo_Finder$com_nim_domain_user_external_FacebookUserDetail$findFacebookUserDetailsByUserIdEquals(paramString); }
public String toString() { return FacebookUserDetail_Roo_ToString.ajc$interMethod$com_nim_domain_user_external_FacebookUserDetail_Roo_ToString$com_nim_domain_user_external_FacebookUserDetail$toString(this); }
}
Decompiled FacebookUserDetail.class from project2
package com.***.domain.user.external;
import com.***.domain.user.UserDetailType;
import org.aspectj.lang.JoinPoint;
import org.aspectj.runtime.internal.CFlowCounter;
import org.aspectj.runtime.reflect.Factory;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.aspectj.AbstractDependencyInjectionAspect;
import org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect;
import org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl;
public class FacebookUserDetail extends ExternalUserDetail
{
public FacebookUserDetail()
{
JoinPoint localJoinPoint = Factory.makeJP(ajc$tjp_1, this, this); if ((!AnnotationBeanConfigurerAspect.ajc$if$bb0((Configurable)getClass().getAnnotation(Configurable.class))) && (AbstractDependencyInjectionAspect.ajc$if$6f1(localJoinPoint))) AnnotationBeanConfigurerAspect.aspectOf().ajc$afterReturning$org_springframework_beans_factory_aspectj_AbstractDependencyInjectionAspect$2$1ea6722c(this);
}
public static FacebookUserDetail findFacebookUserDetailByFacebookId(String facebookId)
{
String str = facebookId; JoinPoint localJoinPoint = Factory.makeJP(ajc$tjp_0, null, null, str); if ((AnnotationDrivenStaticEntityMockingControl.ajc$cflowCounter$1.isValid()) && (AnnotationDrivenStaticEntityMockingControl.hasAspect())) return (FacebookUserDetail)findFacebookUserDetailByFacebookId_aroundBody1$advice(str, localJoinPoint, AnnotationDrivenStaticEntityMockingControl.aspectOf(), null, ajc$tjp_0, localJoinPoint); return findFacebookUserDetailByFacebookId_aroundBody0(str, localJoinPoint);
}
public UserDetailType getExternalUserDetailType()
{
return UserDetailType.FACEBOOK;
}
static
{
ajc$preClinit();
}
}
My question is: What are possible reasons for truncated class file in project2?
As far as I understand from the error you have the following scenario:
you request an entity of type UserDetail with that ID (which should have the DTYPE/discriminator column value equal to FacebookUserDetail or other that extend UserDetail), but in your DB the DTYPE is another. You have to correct your DB for that.
Or it could also be, that FacebookUserDetail is not recognized as being a DTYPE of the same hierarchy. Try debugging a bit, e.g testing what is returned if you search for a FacebookUserDetail instance of the same ID.
It looks like your super class and subclasse didn't share the same id in the database for the requested record 1501237
It is obvious you have an inheritance problem, take a look at http://en.wikibooks.org/wiki/Java_Persistence/Inheritance