Vinay Taneja

+ Follow
since Apr 04, 2012
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Vinay Taneja

actually thinking of foreign key would be data centric and I am thinking from componentisation point of view. In actual all the refrential contraints are being managed in database itself, and if I want to fetch entities from reverse direction, I can do it in database and if I know the instance of service I can also configure the correct target entity. Comment is just an example but in real life, cheese is just cheese be it on garlic bread or pizza.

And if we talk about EJB concepts where remoting is possible, lets say CommentsBean is on different server and I am putting comment on my UserBean so I need not to maintain any reference to entity in my User entity and viceversa.
I don't want to design that if I fetch one Entity all the data of my database comes with it. Like if I fetch one user, all the comments are linked with it in entity and all the other work and entities which are associated with that user and then any shared entity where user A worked and user B too, B is also linked through that shared entity path. I mean a user is a user only.

So its like, I want to create one component which can store data in different tables based on configuration. I think it was possible with normal old EJB concepts.
I want to develop one component which will perform certain CRUD eg: note or comment. Now note can be placed on many entities in a system and I want to maintain them in different tables for each entity. what I want is that I just configure table name in my orm.xml and use same Comment.class as class and specify that name in my service instance of spring configuration and it should do CRUD based on that name.

Which eventually means I am saying when I use instance A of my service which is configured to use name commentsA for Comment entity it will do CRUD on table_a while when I use instance B of my same service which is configured to use name commentB for Comment, it will work on table_b.

<bean id="instanceA" class="test.MyService">
<constructor-arg value="commentsA"/>
<constructor-arg value="entityMgrFac"/>

<bean id="instanceB" class="test.MyService">
<constructor-arg value="commentsB"/>
<constructor-arg value="entityMgrFac"/>

<bean id="entityOneService" class="test.EntityOneService">
<constructor-arg value="instanceA"/>

<bean id="entityTwoService" class="test.EntityTwoService">
<constructor-arg value="instanceB"/>

however one question I have is what is the meaning of having name attribute in entity if we can not use it.

I have one entity class and want to map it to more than one table eg: Comment is entity class and a comment can be on different entities in the system so for entity A comment will be stored in CommentA table for entity B comment will be stored in CommentB table. now I want to map same Comment class with different table through orm.xml and there I can map same class with different tables with different name attribute.

But now how to persist instance of Entity as in persist method it takes only entity class instance and will store it in which table?
the same way how to update?

I am not looking for MappedSuperClass option.
As I said it is not IS A relation but has a relation, it is not subclassing. A is complete by itself and does not need any data from B/C/D but table A has foreign key column which can have value from any of B/C/D. I need to select records of A type based on some where condition on B/C/D. Also it can be many unions at runtime
its like
select * from (
select A.* from table A,table B where and B.somecolumn='abcdefg'
select A.* from table A,table B where and B.someOthercolumn=1245
select A.* from table A,table C where and C.yetAnothercolumn='xyz')
order by 1

now in above eg. I joined A and B twice, at any runtime it can be joined many times with different where condition. Also A has its own primary key id.
It is not IS A relation between tables A/B/C/D it is simple adhoc join where I want to UNION output of any number of queries that will be data driven. Also A/B/C/D entities are all independent they can have have HAS A relation with others but not IS A.
it is not simple case of descriptor column because no inheritance.

I know UNION and a lot of simple stuff is not possible in hibernate but that is what I need with dynamic where clause and JOIN with having order by on result of UNION.

I want to create a relationship on one table with multiple tables based on value in another column. How can I do that in hibernate.

Rejections table has two columns ref_id and ref_type and based on the value of ref_type, it will look for in different tables. if ref_type is "soft" it will look into softwares table for ref_id, if ref_type is "service" it will look into services table for same ref_id.

basically table A has one reference column and on reference type column (descriptor column). Table A joins to Table B, Table C and Table D on same reference columns but based on descriptor column value. Table B/C/D all are distinct entities of different type and have no relation logically and domain wise. Item created by Table A will have has a relationship with these tables. I want to fetch Table A records based on some joins which can join A with any of B/C/D.

its like
select * from (
select A.* from table A,table B where and B.somecolumn='abcdefg'
select A.* from table A,table C where and C.somecolumn='xyz')
order by 1
This is how I am planning to put my data
Questions table
id|question |opt1 |opt2 |opt3 |opt4 |opt5 |marks
1|what are the valid access qualifiers of a class |public |default|private |protected |null |2
2|what are the valid implementations of java.util.Collection|ArrayList|Arrays|Collections|HashSet |Vector|3

Answers table
1 |1
1 |2
2 |1
2 |4
2 |5

I have a very simple basic requirement creating application for taking papers of any domain. In this application, I store questions in questions table and its answers which can be single or multi in answers table.
I have table questions(id,question, ans1,ans2,ans3,ans4) and table answers(question_id,answer_id). Now in answers table there is no primary key, or I can make both the columns as primary key. also in my domain object Question I have a collection of Answers but my problem is because in table answers there are only two columns and in actual I don't need a class to represent this table, should I still create an Entity class for answers. Also what should be the primary key of this table, if we take both columns as the primary key, what should be generation strategy in entity class. Also what will be join condition.

I am new to JPA and trying to do some testing and practice. I have a very specific scenario, I have two entities as below
Mapped to person class as single table

extends Person and fields specific to customer are stored in customer table however person related fields are stored in person class/table itself.

Now what I want is I don't want to describe a descriptor in person table as a person record in this table is complete itself to define a person however when i ask for a customer JPA should map person record in person table and fetch them in customer instance. As customer class extends person class it has all the fields.

What actually I want is a customer is anyway a person so by inheritance it gets all the fields of person. but because person is mapped to person table and it has all its persisting fields mapped to person table. When I try to load or save person object it tries to fetch dtype column (descriptor) but in actual when I try to fetch person i just need a person definition not its customer fields and a person can also be inherited by employee class or a normal person itself (no need to be customer or no need to be an employee).

Please help!