Sreyan Chakravarty

Ranch Hand
+ Follow
since Oct 07, 2014
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Sreyan Chakravarty

I am kind of feeling like a loser now.

SCJP 6 was retired. I have an OCWCD certification, what do I do? Do I upgrade my SCJP 6? Or do I get a better certification like OCBCD or OCP?

I am completely confused.
Say I have an entity called Employee with a String persistent field called "id". Now say by using a JPQL query I only wish to project the id of a particular employee. What will be the return type of that query ? List<Object[]> or String ? I am confused since I heard that project queries returns only List<Object[]> but in this case it makes more sense to return only a String object.

Also how would I write such a query ?



Would the above query work ?

Also what would be the return type of aggregate functions like COUNT or SUM ? Single integer or list of Objects ?

Roel De Nijs wrote:

Sreyan Chakravarty wrote:Is it part of JPA or Hibernate specifically ?


If you have a look at the JPA package sumary, you'll see no mention of ForceDiscriminator so it's Hbernate specific.



So just correct me if I am wrong. @forcediscriminator just adds the discriminator to the WHERE clause right ?

Roel De Nijs wrote:I think this article describes pretty well why you need to use the @ForceDiscriminator annotation.



Is it part of JPA or Hibernate specifically ?
I googled a lot to no avail. What is the use of the annotation called @forcediscriminator ? Is it used to force the discriminator in the WHERE clause ? Why doesn't a JPA provider use the discriminator in the WHERE clause by default ? The existence of such an annotation seems kinda redundant to me.

A.J. Côté wrote:Strange... How can you tell that your constraints are inherited if export schema fails?



The schema export does not completely fail. Just for the table that I have given in my topic. All the other tables are exported properly.

Kai Prünte wrote:IMO this is a bug in Hibernate 5.
I have the same issue in Hibernate 5.0.1. The same code with Hibernate 4.x works fine.



Are you sure it works fine in Hibernate 4 ?

A.J. Côté wrote:Hello,

I do not think it is a bug. Since you have no common table, you would need to define the constraint in every subclass table. I don't think constraints can be inherited.

Consider using InheritanceType.JOINED or even InheritanceType.SINGLE_TABLE if you want to declare the constraint only once for all your subclasses.

That is my understanding but I haven't investigated in depth.



Constraints are being inherited. My sub classes are being mapped with the correct constraint. I cannot use JOINED or SINGLE_TABLE because of my requirement and performance reasons.


I have the following error in my Hibernate log. I am using ONLY the JPA facilities of Hibernate to map my tables to MySQL. Now the above error makes since Subject is defined like the following-:




Its an abstract entity and not a mapped super class since I need to use it in queries.

Now I have a subclass of Subject called Theory which is a normal entity.

My question is that why is hibernate TRYING to add a constraint to an abstract entity ? Should'nt it be smart enough and the see the TABLE_PER_CLASS strategy placed there. Should'nt it only refer to the child classes ? If its abstract there is no way of an entity existing.

Is this a bug in the Hibernate code ?

Using version 5.0.0.CR4

Roel De Nijs wrote:

Sreyan Chakravarty wrote:Now it says basically to model the Join Table as a separate entity by decomposing all the many-to-many relationships into one-to-many and many-to-one relationships. Now my question is that - doesn't this decomposing into one-to-many and many-to-one destroy the conceptual mapping of many-to-many ?

I mean is one-to-many and many-to-one really the same thing ? Doesn't that destroy the original data model ?


If you don't need additional columns, you can use the @ManyToMany annotation. But if you need additional columns and it seems your data model requires them, so as far as I know there's no other solution than the one described in the link I provided. I don't see any problem with this approach.



I understand. But my question was that is Many-to-one and One-to-Many conceptually same as Many-to-Many ?

Roel De Nijs wrote:

Sreyan Chakravarty wrote:Now one subject can be studied by many students and one student can study many subjects. So its a many to many relationship. Correct me if I am wrong.


You are correct!

Sreyan Chakravarty wrote:Now there can be multiple internal exams that a Student might have to take, thus the number of internals are not fixed, hence internal_no.


For each Subject there are an undefined number of internal exams. So for subject A there could be just one exam, but for subject B there are 5 exams.

So you could have an Exam table { exam_id, internal_no, subject_id } and then the Marks table would be something like { student_id, exam_id, marks }. But that would require an extra join each time you want to query the marks, for example on a specific subject for all students (or one specific student).

Sreyan Chakravarty wrote:Now what is confusing me is this. If Student and Subjects share a many to many relationship then what relationship should hold in the marks table ? Since both Student_id and Subject_id are referenced from Student and Subject table respectively.


You'll need a JoinTable with additional columns. And table Marks will be this join table; Student_id, Subject_id, internal_no will be the composite primary key; and the marks column will be the additional column.



Okay. I have seen the link that you have referred me to.

Now it says basically to model the Join Table as a separate entity by decomposing all the many-to-many relationships into one-to-many and many-to-one relationships. Now my question is that - doesn't this decomposing into one-to-many and many-to-one destroy the conceptual mapping of many-to-many ?

I mean is one-to-many and many-to-one really the same thing ? Doesn't that destroy the original data model ?
I need help with Apache Shiro. Which section should I go to in this forum ? Any suggestions are welcome.
9 years ago

Tim Holloway wrote:The easiest way is with an IDE. Import the Tomcat source code in as a project, run the Tomcat build scripts, configure the resulting copy of Tomcat like you were doing with the prebuilt copy, then launch it using the IDE's "Remote Application" debugging feature. Set breakpoints as desired.



I wish it were as simple as you make it sound.
9 years ago

Tim Holloway wrote:One of the problems with getting free support is that unless it's something I already know or can easily pull out of docs from the same sources as you can, it's too much work for me to do for free.

Unfortunately, this is one of those cases. I normally use the common MD5 encryption, and that's handled by the default mechanisms, so I have had no need to learn the more obscure options.

I can tell you that if my employer required that I go the more complex route that I'd pull the Tomcat source code, do a build and put a breakpoint on the failing instruction to try and see where things were wrong - assuming that I had what I thought were the correct parameters. If you want to try doing that yourself, I can help you in setting up a debugging environment. Actually making sense of it would be mostly up to you.



I already have the source code. Now I need your help on how to set up the debugging environment. How do you do that ?
9 years ago

Tim Holloway wrote:This may be related to your other question. Apparently your Realm is not configured properly, as the "stored credentials" are null instead of a parseable String potentially containing a "$". Or so says the source code for the failing logic.

The "login-error-page" is displayed when login fails because of improper credentials from the user. The "500 Error" page occurs when the credentials could not be compared because of a program logic fault.

In all the years I've worked with Tomcat, I don't think I've ever had the "500" page display on login. The Realm modules aren't expected to fail under proper configuration settings.



Yes so what am I doing wrong ? Where am I going wrong ?
9 years ago