问:
Xamarin Forms app is crashing on funtouch OS and color OS in Android after launched
Xamarin forms app is crashing on vivo Android phones those are operating by funtouch OS and color OS. I have tried to get the reason behind the crash but did not found anything yet. If, someone face this kind of issue, Please give me some of solution to resolve this.

I have tried to debug the problem on the android device but no luck yet. Below are the some screenshots of device details:

Screenshot of one of device on which facing issue (https://i.stack.imgur.com/KybEd.jpg)

Below is the json which received on sentry (hope this will be helpful to understand the problem):

{"event_id":"d3a14f9ea375456fb7042268bf26da9c","project":4504321653669888,"release":"com.tsi.ipay@2.2.9+57","dist":null,"platform":"csharp","message":"","datetime":"2022-12-15T06:58:49.619733Z","tags":[["cpu.model","MT6762V/WR"],["device","vivo 1901"],["environment","production"],["handled","no"],["level","error"],["mechanism","AppDomain.UnhandledException"],["os","Android 11"],["os.name","Android"],["runtime","Mono 6.12.0"],["runtime.name","Mono"],["release","com.tsi.ipay@2.2.9+57"]],"_metrics":{"bytes.ingested.event":9482,"bytes.stored.event":10684},"breadcrumbs":{"values":[{"timestamp":1671087523.203,"type":"navigation","category":"ui.lifecycle","level":"info","data":{"screen":null,"state":"Started"}},{"timestamp":1671087524.469,"type":"navigation","category":"ui.lifecycle","level":"info","data":{"screen":null,"state":"Resumed"}},{"timestamp":1671087525.42,"type":"info","category":"xamarin","level":"warning","data":{"issue":"Material needs to be registered on Android by calling FormsMaterial.Init() after the Xamarin.Forms.Forms.Init method call.","logger":"Visual"}},{"timestamp":1671087526.193,"type":"navigation","category":"ui.lifecycle","level":"info","data":{"popup":"ProcessingView","state":"appearing"}},{"timestamp":1671087526.634,"type":"navigation","category":"ui.lifecycle","level":"info","data":{"screen":"LoginPage","state":"Stopped"}},{"timestamp":1671087526.64,"type":"navigation","category":"ui.lifecycle","level":"info","data":{"screen":"LoginPage","state":"SaveInstanceState"}},{"timestamp":1671087526.645,"type":"navigation","category":"ui.lifecycle","level":"info","data":{"screen":"LoginPage","state":"Destroyed"}},{"timestamp":1671087526.673,"type":"navigation","category":"ui.lifecycle","level":"info","data":{"screen":"LoginPage","state":"Paused"}},{"timestamp":1671087526.675,"type":"session","category":"app.lifecycle","level":"info","message":"Pausing Sentry Session"},{"timestamp":1671087527.032,"type":"navigation","category":"ui.lifecycle","level":"info","data":{"popup":"ProcessingView","state":"disappearing"}},{"timestamp":1671087527.466,"type":"navigation","category":"ui.lifecycle","level":"info","data":{"screen":"LoginPage","state":"Stopped"}},{"timestamp":1671087527.558,"type":"navigation","category":"ui.lifecycle","level":"info","data":{"screen":"LoginPage","state":"SaveInstanceState"}},{"timestamp":1671087528.868,"type":"navigation","category":"ui.lifecycle","level":"info","data":{"screen":"LoginPage","state":"Started"}},{"timestamp":1671087528.985,"type":"navigation","category":"ui.lifecycle","level":"info","data":{"screen":"LoginPage","state":"Resumed"}},{"timestamp":1671087528.992,"type":"session","category":"app.lifecycle","level":"info","message":"Resuming Sentry Session"},{"timestamp":1671087529.116,"type":"navigation","category":"ui.lifecycle","level":"info","data":{"popup":"ProcessingView","state":"appearing"}},{"timestamp":1671087529.635,"type":"session","category":"app.lifecycle","level":"info","message":"Ending Sentry Session"}]},"contexts":{"Current Culture":{"calendar":"GregorianCalendar","display_name":"English (United States)","name":"en-US","type":"Current Culture"},"ThreadPool Info":{"available_completion_port_threads":200,"available_worker_threads":200,"max_completion_port_threads":200,"max_worker_threads":200,"min_completion_port_threads":8,"min_worker_threads":8,"type":"ThreadPool Info"},"app":{"app_start_time":"2022-12-20T02:41:07.506512+00:00","type":"app"},"device":{"model":"vivo 1901","brand":"vivo","screen_resolution":"1544x720","screen_density":2.0,"online":true,"simulator":false,"memory_size":3994288128,"free_memory":1182928896,"storage_size":7427833856,"boot_time":"2022-12-08T07:52:14.6011828+00:00","timezone":"Asia/Kolkata","type":"device"},"os":{"name":"Android","version":"11","type":"os"},"runtime":{"name":"Mono","version":"6.12.0","raw_description":"Mono 6.12.0 (2020-02/a96bde9730e)","type":"runtime"}},"culprit":"","environment":"production","exception":{"values":[{"type":"Java.Lang.IllegalArgumentException","value":"No view found for id 0x2f (unknown) for fragment FragmentContainer{97112ae} (76e149fc-19ce-41a0-979b-c1893d7eda70 id=0x2f)","module":"Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065","thread_id":1,"mechanism":{"type":"AppDomain.UnhandledException","handled":false}}]},"fingerprint":["{{ default }}"],"grouping_config":{"enhancements":"eJybzDRxY3J-bm5-npWRgaGlroGxrpHxBABcYgcZ","id":"newstyle:2019-10-29"},"hashes":["0a1736c5ae9bad56b6e497c577a455ec"],"key_id":"2798897","level":"error","logger":"","metadata":{"display_title_with_tree_label":false,"type":"Java.Lang.IllegalArgumentException","value":"No view found for id 0x2f (unknown) for fragment FragmentContainer{97112ae} (76e149fc-19ce-41a0-979b-c1893d7eda70 id=0x2f)"},"modules":{"AEPS":"1.0.0.0","AEPS.Android":"1.0.0.0","AEPS.BAL":"1.0.0.0","AEPS.Models":"1.0.0.0","AutoMapper":"10.0.0.0","Cashfree.Forms.Payment.Gateway":"0.9.2.0","DocumentFormat.OpenXml":"2.18.0.0","FFImageLoading":"2.4.11.982","FFImageLoading.Forms":"2.4.11.982","FFImageLoading.Forms.Platform":"2.4.11.982","FFImageLoading.Platform":"2.4.11.982","FastAndroidCamera":"2.0.0.0","Forms9Patch":"1.0.0.0","Forms9Patch.Droid":"1.0.0.0","FormsGestures":"1.0.0.0","FormsGestures.Droid":"1.0.0.0","FormsViewGroup":"2.0.0.0","HighlightMarker":"3.0.11.0","HighlightMarker.Forms":"3.0.11.0","Java.Interop":"0.1.0.0","Microsoft.AppCenter":"0.0.0.0","Microsoft.AppCenter.Analytics":"0.0.0.0","Microsoft.AppCenter.Crashes":"0.0.0.0","Microsoft.Bcl.AsyncInterfaces":"6.0.0.0","Microsoft.Extensions.Configuration":"6.0.0.0","Microsoft.Extensions.Configuration.Abstractions":"6.0.0.0","Microsoft.Extensions.Configuration.Binder":"6.0.0.0","Microsoft.Extensions.Configuration.CommandLine":"6.0.0.0","Microsoft.Extensions.Configuration.EnvironmentVariables":"6.0.0.0","Microsoft.Extensions.Configuration.FileExtensions":"6.0.0.0","Microsoft.Extensions.Configuration.Json":"6.0.0.0","Microsoft.Extensions.Configuration.UserSecrets":"6.0.0.0","Microsoft.Extensions.DependencyInjection":"6.0.0.0","Microsoft.Extensions.DependencyInjection.Abstractions":"6.0.0.0","Microsoft.Extensions.FileProviders.Abstractions":"6.0.0.0","Microsoft.Extensions.FileProviders.Physical":"6.0.0.0","Microsoft.Extensions.FileSystemGlobbing":"6.0.0.0","Microsoft.Extensions.Hosting":"6.0.0.0","Microsoft.Extensions.Hosting.Abstractions":"6.0.0.0","Microsoft.Extensions.Logging":"6.0.0.0","Microsoft.Extensions.Logging.Abstractions":"6.0.0.0","Microsoft.Extensions.Logging.Configuration":"6.0.0.0","Microsoft.Extensions.Logging.Console":"6.0.0.0","Microsoft.Extensions.Logging.Debug":"6.0.0.0","Microsoft.Extensions.Logging.EventLog":"6.0.0.0","Microsoft.Extensions.Logging.EventSource":"6.0.0.0","Microsoft.Extensions.Options":"6.0.0.0","Microsoft.Extensions.Options.ConfigurationExtensions":"6.0.0.0","Microsoft.Extensions.Primitives":"6.0.0.0","MimeSharp":"1.0.0.0","Mono.Android":"0.0.0.0","Mono.Security":"2.0.5.0","Newtonsoft.Json":"13.0.0.0","P42.NumericalMethods":"1.0.0.0","P42.Utils":"1.0.0.0","P42.Utils.Droid":"1.0.0.0","PlayCore":"1.10.2.0","Plugin.ImageEdit":"1.0.0.0","Plugin.ImageEdit.Abstractions":"1.0.0.0","RazorBindingLibrary":"1.0.0.0","Sentry":"3.23.1.0","Sentry.Xamarin":"1.4.5.0","Sentry.Xamarin.Forms":"1.4.5.0","SkiaSharp":"2.80.0.0","SkiaSharp.Extended.Svg":"1.60.0.0","SkiaSharp.Views.Android":"2.80.0.0","SkiaSharp.Views.Forms":"2.80.0.0","System":"2.0.5.0","System.Collections.Immutable":"5.0.0.0","System.Core":"2.0.5.0","System.Data":"2.0.5.0","System.Diagnostics.DiagnosticSource":"6.0.0.0","System.Diagnostics.EventLog":"6.0.0.0","System.Drawing.Common":"4.0.0.0","System.IO.Compression":"2.0.5.0","System.IO.Packaging":"4.0.5.0","System.Net.Http":"4.0.0.0","System.Numerics":"2.0.5.0","System.Reflection.Metadata":"5.0.0.0","System.Runtime.CompilerServices.Unsafe":"6.0.0.0","System.Runtime.Serialization":"2.0.5.0","System.Security.Principal.Windows":"5.0.0.0","System.Text.Encodings.Web":"6.0.0.0","System.Text.Json":"6.0.0.0","System.Xml":"2.0.5.0","System.Xml.Linq":"2.0.5.0","Xamarin.AndroidX.Activity":"1.0.0.0","Xamarin.AndroidX.AppCompat":"1.0.0.0","Xamarin.AndroidX.AppCompat.AppCompatResources":"1.0.0.0","Xamarin.AndroidX.CardView":"1.0.0.0","Xamarin.AndroidX.CoordinatorLayout":"1.0.0.0","Xamarin.AndroidX.Core":"1.0.0.0","Xamarin.AndroidX.CursorAdapter":"1.0.0.0","Xamarin.AndroidX.CustomView":"1.0.0.0","Xamarin.AndroidX.DrawerLayout":"1.0.0.0","Xamarin.AndroidX.Fragment":"1.0.0.0","Xamarin.AndroidX.Legacy.Support.Core.UI":"1.0.0.0","Xamarin.AndroidX.Lifecycle.Common":"1.0.0.0","Xamarin.AndroidX.Lifecycle.LiveData.Core":"1.0.0.0","Xamarin.AndroidX.Lifecycle.ViewModel":"1.0.0.0","Xamarin.AndroidX.Loader":"1.0.0.0","Xamarin.AndroidX.RecyclerView":"1.0.0.0","Xamarin.AndroidX.SavedState":"1.0.0.0","Xamarin.AndroidX.SwipeRefreshLayout":"1.0.0.0","Xamarin.AndroidX.VersionedParcelable":"1.0.0.0","Xamarin.AndroidX.ViewPager":"1.0.0.0","Xamarin.Essentials":"1.0.0.0","Xamarin.Firebase.Common":"1.0.0.0","Xamarin.Firebase.Encoders":"1.0.0.0","Xamarin.Firebase.Encoders.Proto":"1.0.0.0","Xamarin.Firebase.Messaging":"1.0.0.0","Xamarin.Forms.Core":"2.0.0.0","Xamarin.Forms.Platform":"2.0.0.0","Xamarin.Forms.Platform.Android":"2.0.0.0","Xamarin.Forms.Xaml":"2.0.0.0","Xamarin.Google.Android.DataTransport.TransportApi":"1.0.0.0","Xamarin.Google.Android.DataTransport.TransportBackendCct":"1.0.0.0","Xamarin.Google.Android.DataTransport.TransportRuntime":"1.0.0.0","Xamarin.Google.Android.Material":"1.0.0.0","Xamarin.Google.Dagger":"1.0.0.0","Xamarin.Google.ErrorProne.Annotations":"1.0.0.0","Xamarin.Google.Guava.ListenableFuture":"1.0.0.0","Xamarin.GooglePlayServices.Base":"1.0.0.0","Xamarin.GooglePlayServices.Basement":"1.0.0.0","Xamarin.GooglePlayServices.Tasks":"1.0.0.0","Xamarin.JavaX.Inject":"1.0.0.0","Xamarin.Jetbrains.Annotations":"1.0.0.0","Xamarin.Kotlin.StdLib":"1.0.0.0","Xamarin.Kotlin.StdLib.Common":"1.0.0.0","ZXing.Net.Mobile.Core":"2.4.1.0","ZXing.Net.Mobile.Forms":"2.4.1.0","ZXing.Net.Mobile.Forms.Android":"2.4.1.0","ZXingNetMobile":"2.4.1.0","iPay.BAL":"1.0.0.0","iPay.Models":"1.0.0.0","iPay.Services":"1.0.0.0","mscorlib":"2.0.5.0","zxing.portable":"0.16.2.0"},"nodestore_insert":1671087531.574328,"received":1671087530.695406,"sdk":{"name":"sentry.dotnet.xamarin-forms","version":"1.4.5","packages":[{"name":"nuget:sentry.dotnet","version":"3.23.1"},{"name":"sentry.dotnet.xamarin-forms","version":"1.4.5"}]},"timestamp":1671087529.619733,"title":"Java.Lang.IllegalArgumentException: No view found for id 0x2f (unknown) for fragment FragmentContainer{97112ae} (76e149fc-19ce-41a0-9...","type":"error","version":"7","location":null}

Here is the link for build logs https://drive.google.com/file/d/1dOUU9eXP2X3vm3mtSeJ3Ytm6HxTN4l03/view?usp=sharing

Please let me know if require more details


来源: stackexchange

问:
How to create a reusable components that do not have the same props?
I am new to react and I am trying to create a reusable component. Below is the layout of the component.

```<code> <TestLayout
          header={`©${year} Hello foo`}
          description={"test"}
          link={"link1"}
        />
        <TestLayout header={`©${year} Hello char }`} link={"link2"} />
</code>```
```<code>const TestLayout = (props) => {
  return (
    <>
      <p>{props.header}</p>
      <p>{props.link}</p>
      <p>{props.description}</p>
    </>
  );
};

export default TestLayout;
</code>```

As seen above, I did not pass the description prop on the second component to experiment with the output. I would like to know if this will cause any huge problems as the app scales larger.

Right now, there are no errors and the second component will just not display the description but what if I have multiple components that have different properties that need to be displayed, and not all of the components will have similar properties? How can I better structure my reusable component?

ContentLicense: CC BY-SA 4.0

Body:
I am new to react and I am trying to create a reusable component. Below is the layout of the component.

 <TestLayout
          header={`©${year} Hello foo`}
          description={"test"}
          link={"link1"}
        />
        <TestLayout header={`©${year} Hello char }`} link={"link2"} />

const TestLayout = (props) => {
  return (
    <>

{props.header}

{props.link}

{props.description}

    </>
  );
};

export default TestLayout;

As seen above, I did not pass the description prop on the second component to experiment with the output. I would like to know if this will cause any huge problems as the app scales larger.

Right now, there are no errors and the second component will just not display the description but what if I have multiple components that have different properties that need to be displayed, and not all of the components will have similar properties? How can I better structure my reusable component?


问:
Why this code gives me very low validation accuracy in image forgery detection (binary image classification problem)
I am trying to build DNN with the help of the pretrained models ResNet50 in image forgery classification problem, but it gave me low validation accuracy (not more than 68%) while its paper said that it gave 96% accuracy. I want to know what is the logical or technical error in my code? I must use a standard data set which is 2000 images, I tried to use augmentation, but it gave me lower accuracy (not more than 59%)

This is my code ...

```<code>train_data=ImageDataGenerator()

test_data=ImageDataGenerator()
valid_data=ImageDataGenerator()

training=train_data.flow_from_directory(train_list,
                                target_size=(224,224),

                                batch_size=20,
                                shuffle=False,
                                class_mode="binary")

valid=valid_data.flow_from_directory(valid_list,
                                  target_size=(224,224),

                                  batch_size=20,
                                  shuffle=False,
                                  class_mode="binary")

testing=test_data.flow_from_directory(test_list,
                                  target_size=(224,224),

                                  batch_size=20,
                                  shuffle=False,
                                  class_mode="binary")

# create model
resnet_model=ResNet50(weights='imagenet', include_top=False, input_shape=(224, 224, 3),         pooling='max')

model_aug=Sequential()
model_aug.add(resnet_model)

top_model=Sequential()
top_model.add(Flatten())

top_model.add(Dense(512, activation='relu'))
# model_aug.add(Dropout(0.2))

top_model.add(Dense(1, activation='sigmoid'))

model_aug.add(top_model)

for layer in model_aug.layers[0].layers[:171]:
    layer.trainable=False

print(model_aug.summary())

opt = tf.keras.optimizers.Adam(learning_rate=0.001)
model_aug.compile(optimizer=opt,
          loss="binary_crossentropy",
          metrics=['accuracy'])

checkpoint_filepath = 'd://checkpoint/Q_resnet_casia2_checkpoint//'
model_checkpoint_callback = keras.callbacks.ModelCheckpoint(
    filepath=checkpoint_filepath,
    save_weights_only=True,
    monitor='val_accuracy',
    mode='max',
    save_best_only=True)

history = model_aug.fit(training,validation_data=valid,
                epochs=100,steps_per_epoch=len(training),
                validation_steps=len(valid)
               ,callbacks=[model_checkpoint_callback] , verbose=1)

model_aug.load_weights(checkpoint_filepath)
# evaluate the model
test_loss, test_acc = model_aug.evaluate(testing,verbose=1, steps=len(testing))
print(" acc=", test_acc)
</code>```

The validation accuracy =68% and it expected to be 96% I want to know what is the logical or technical error here?

Body:
I am trying to build DNN with the help of the pretrained models ResNet50 in image forgery classification problem, but it gave me low validation accuracy (not more than 68%) while its paper said that it gave 96% accuracy. I want to know what is the logical or technical error in my code? I must use a standard data set which is 2000 images, I tried to use augmentation, but it gave me lower accuracy (not more than 59%)

This is my code ...

train_data=ImageDataGenerator()

test_data=ImageDataGenerator()
valid_data=ImageDataGenerator()

training=train_data.flow_from_directory(train_list,
                                target_size=(224,224),

                                batch_size=20,
                                shuffle=False,
                                class_mode="binary")

valid=valid_data.flow_from_directory(valid_list,
                                  target_size=(224,224),

                                  batch_size=20,
                                  shuffle=False,
                                  class_mode="binary")

testing=test_data.flow_from_directory(test_list,
                                  target_size=(224,224),

                                  batch_size=20,
                                  shuffle=False,
                                  class_mode="binary")

# create model
resnet_model=ResNet50(weights='imagenet', include_top=False, input_shape=(224, 224, 3),         pooling='max')

model_aug=Sequential()
model_aug.add(resnet_model)

top_model=Sequential()
top_model.add(Flatten())

top_model.add(Dense(512, activation='relu'))
# model_aug.add(Dropout(0.2))

top_model.add(Dense(1, activation='sigmoid'))

model_aug.add(top_model)

for layer in model_aug.layers[0].layers[:171]:
    layer.trainable=False

print(model_aug.summary())

opt = tf.keras.optimizers.Adam(learning_rate=0.001)
model_aug.compile(optimizer=opt,
          loss="binary_crossentropy",
          metrics=['accuracy'])

checkpoint_filepath = 'd://checkpoint/Q_resnet_casia2_checkpoint//'
model_checkpoint_callback = keras.callbacks.ModelCheckpoint(
    filepath=checkpoint_filepath,
    save_weights_only=True,
    monitor='val_accuracy',
    mode='max',
    save_best_only=True)

history = model_aug.fit(training,validation_data=valid,
                epochs=100,steps_per_epoch=len(training),
                validation_steps=len(valid)
               ,callbacks=[model_checkpoint_callback] , verbose=1)

model_aug.load_weights(checkpoint_filepath)
# evaluate the model
test_loss, test_acc = model_aug.evaluate(testing,verbose=1, steps=len(testing))
print(" acc=", test_acc)

The validation accuracy =68% and it expected to be 96% I want to know what is the logical or technical error here?


问:
Index a multi-dimensional numpy array by a variable that contains a list of slices
I have a piece of code that uses a sophisticated way of calculating slices for an array that used to work, but does not any more as of python 3.8.15.

Can anyone tell me whats wrong with

```<code>>>> a=np.zeros((100,100))
>>> b=[slice(5,95),slice(5,95)]
>>> a[b]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

</code>```

and moreover how to do it correctly?

I'm pretty sure it worked up to python about 3.5 ...

Body:
I have a piece of code that uses a sophisticated way of calculating slices for an array that used to work, but does not any more as of python 3.8.15.

Can anyone tell me whats wrong with

>>> a=np.zeros((100,100))
>>> b=[slice(5,95),slice(5,95)]
>>> a[b]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

and moreover how to do it correctly?

I'm pretty sure it worked up to python about 3.5 ...


问:
Laravel session sharing in two projects not working
I have a Laravel 5.3 and a Laravel 9 project and I want to share the session between them.
The session driver is database and the both projects using the same.

I read for sharing a session you need to:

having identical cookie name (check)

same cookie domain (check)

Identical APP_KEY for encrypt/decrypt (check)

same domain (check)

Still after I login at the Laravel 5.3 app and hit a Laravel 9 route (which is managed by the load balancer) I got 401. After when it redirects me to a the laravel 5.3 login route, it shows me 500 somehow... and when I clear the cookies, the page loads up fine.
I suspect the problem lies in the cookie encrypt/decrypt part.

Somebody got a solution for this?


问:
How do I add Multiple AI Difficulties to my func computerPlay() in my UIViewController? I am creating a tic tac toe game in UIKit
How do I add Multiple AI Difficulties to my func computerPlay() in my UIViewController? I am creating a tic tac toe game in UIKit
I know how to do it in swiftui from another project. I don't know how to change their names to the correct code in my project. I have tried and kept failing. Right now when you play against the computer and try to lose, majority of the time you will get a draw or a force win. Please help.</p>
```<code>//
//  xoGame.swift
//  TicBones
//
//  Created by Carissa Richardson on 12/8/22.
//

import UIKit
import SwiftUI
class xoGame: UIViewController {

    @IBOutlet weak var playerScore3: UILabel!
    @IBOutlet weak var a2: UIImageView!
    @IBOutlet weak var a3: UIImageView!
    @IBOutlet weak var b1: UIImageView!
    @IBOutlet weak var b2: UIImageView!
    @IBOutlet weak var b3: UIImageView!
    @IBOutlet weak var c1: UIImageView!
    @IBOutlet weak var c2: UIImageView!
    @IBOutlet weak var c3: UIImageView!

    @IBOutlet weak var backgroundLabel: UIImageView!
    @IBOutlet weak var a1: UIImageView!

    var gameP1 = "o"
    var playerChoices: [Box2] = []
    var computerChoices: [Box2] = []

    override func viewDidLoad() {
        super.viewDidLoad()
        createTap(on: a1, type: .one)
        createTap(on: a2, type: .two)
        createTap(on: a3, type: .three)
        createTap(on: b1, type: .four)
        createTap(on: b2, type: .five)
        createTap(on: b3, type: .six)
        createTap(on: c1, type: .seven)
        createTap(on: c2, type: .eight)
        createTap(on: c3, type: .nine)

    }
    @IBOutlet weak var computerScore3: UILabel!

    func createTap(on imageView: UIImageView, type box: Box2){
        let tap = UITapGestureRecognizer(target: self, action: #selector(self.boxClicked(_:)))
        tap.name = box.rawValue
        imageView.isUserInteractionEnabled = true
        imageView.addGestureRecognizer(tap)
    }
    @objc func boxClicked(_ sender: UITapGestureRecognizer){
        //        print("Box: \(sender.name) was clicked")
        let selectedBox = getBox(from: sender.name ?? "")
        makeChoice(selectedBox)
        playerChoices.append(Box2(rawValue: sender.name!)!)
        checkIfWon()

        DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
            self.computerPlay()
        }
    }
    func computerPlay(){
        var availableSpaces = [UIImageView]()
        var availableBoxes = [Box2]()
        for name in Box2.allCases {
            let box = getBox(from: name.rawValue)
            if box.image == nil {
                availableSpaces.append(box)
                availableBoxes.append(name)
            }
        }

        guard availableBoxes.count > 0 else { return }

// THIS IS WERE I NEED HELP!
// If AI can win, than win
    //If AI cant win, than block
    // If AI cant block, then take middle source
    //If AI cant take middle square, take random available square

 let randIndex = Int.random(in: 0 ..< availableSpaces.count)
        makeChoice(availableSpaces[randIndex])
        computerChoices.append(availableBoxes[randIndex])
        checkIfWon()
    }

    func makeChoice(_ selectedBox: UIImageView) {
        guard selectedBox.image == nil else { return }

        if gameP1 == "x" {
            selectedBox.image = #imageLiteral(resourceName: "O")
            gameP1 = "o"
        } else {
            selectedBox.image = #imageLiteral(resourceName: "x")
            gameP1 = "x"
        }
    }
    func checkIfWon() {
        var correct = [[Box2]]()
        let firstRow: [Box2] = [.one, .two, .three]
        let secondRow: [Box2] = [.four, .five, .six]
        let thirdRow: [Box2] = [.seven, .eight, .nine]

        let firstCol: [Box2] = [.one, .four, .seven]
        let secondCol: [Box2] = [.two, .five, .six]
        let thirdCol: [Box2] = [.three, .six, .nine]

        let backwardSlash: [Box2] = [.one, .five, .nine]
        let forwardSlash: [Box2] = [.three, .five, .seven]

        correct.append(firstRow)
        correct.append(secondRow)
        correct.append(thirdRow)
        correct.append(firstCol)
        correct.append(secondCol)
        correct.append(thirdCol)
        correct.append(backwardSlash)
        correct.append(forwardSlash)

        for valid in correct {
            let userMatch = playerChoices.filter { valid.contains($0) }.count
            let computerMatch = computerChoices.filter { valid.contains($0) }.count

            if userMatch == valid.count {
                playerScore3.text = String((Int(playerScore3.text ?? "0") ?? 0) + 1)
                resetGame()
                break
            } else if computerMatch == valid.count {
                computerScore3.text = String((Int(computerScore3.text ?? "0") ?? 0) + 1)
                resetGame()
                break
            } else if computerChoices.count + playerChoices.count == 9 {
                resetGame()
                break
            }
        }

    }
    func resetGame() {
        for name in Box2.allCases {
            let box = getBox(from: name.rawValue)
            box.image = nil
        }
        gameP1 = "o"
        playerChoices = []
        computerChoices = []
    }

    func getBox(from name: String) -> UIImageView {
        let box = Box2(rawValue: name) ?? .one

        switch box {
        case .one:
            return a1
        case .two:
            return a2
        case .three:
            return a3
        case .four:
            return b1
        case .five:
            return b2
        case .six:
            return b3
        case .seven:
            return c1
        case .eight:
            return c2
        case .nine:
            return c3
        }
    }

    @IBAction func dice(_ sender: Any) {
        backgroundLabel.image = [ #imageLiteral(resourceName: "Screen Shot 2022-08-10 at 10.52.27 PM"), #imageLiteral(resourceName: "Screen Shot 2022-08-10 at 12.18.19 AM"),  #imageLiteral(resourceName: "Screen Shot 2022-07-04 at 3.43.07 PM"), #imageLiteral(resourceName: "Screen Shot 2022-08-10 at 10.53.00 PM"),  #imageLiteral(resourceName: "Screen Shot 2022-08-10 at 11.56.06 PM"), #imageLiteral(resourceName: "Screen Shot 2022-07-04 at 3.11.02 PM"),  #imageLiteral(resourceName: "Ice Cream In Paper Cut Background"), #imageLiteral(resourceName: "Screen Shot 2022-07-04 at 3.11.02 PM"), #imageLiteral(resourceName: "Screen Shot 2022-08-10 at 12.28.13 AM"), #imageLiteral(resourceName: "Screen Shot 2022-08-10 at 10.52.03 PM"),  #imageLiteral(resourceName: "IMG_9062"),  #imageLiteral(resourceName: "IMG_9064"), #imageLiteral(resourceName: "IMG_9061"), #imageLiteral(resourceName: "IMG_9063"), #imageLiteral(resourceName: "IMG_9065"), #imageLiteral(resourceName: "Screen Shot 2022-07-04 at 3.10.05 PM"), #imageLiteral(resourceName: "backPinkbirth"), #imageLiteral(resourceName: "skybackground"), ][Int.random(in: 0...17)]
    }

    @IBAction func refresh(_ sender: Any) {
        self.dismiss(animated: true, completion: nil)
    }
    enum Box2: String, CaseIterable{
        case one, two, three, four, five, six, seven, eight, nine
    }

}
</code>```

Body:
How do I add Multiple AI Difficulties to my func computerPlay() in my UIViewController? I am creating a tic tac toe game in UIKit
I know how to do it in swiftui from another project. I don't know how to change their names to the correct code in my project. I have tried and kept failing. Right now when you play against the computer and try to lose, majority of the time you will get a draw or a force win. Please help.

//
//  xoGame.swift
//  TicBones
//
//  Created by Carissa Richardson on 12/8/22.
//

import UIKit
import SwiftUI
class xoGame: UIViewController {

    @IBOutlet weak var playerScore3: UILabel!
    @IBOutlet weak var a2: UIImageView!
    @IBOutlet weak var a3: UIImageView!
    @IBOutlet weak var b1: UIImageView!
    @IBOutlet weak var b2: UIImageView!
    @IBOutlet weak var b3: UIImageView!
    @IBOutlet weak var c1: UIImageView!
    @IBOutlet weak var c2: UIImageView!
    @IBOutlet weak var c3: UIImageView!

    @IBOutlet weak var backgroundLabel: UIImageView!
    @IBOutlet weak var a1: UIImageView!

    var gameP1 = "o"
    var playerChoices: [Box2] = []
    var computerChoices: [Box2] = []

    override func viewDidLoad() {
        super.viewDidLoad()
        createTap(on: a1, type: .one)
        createTap(on: a2, type: .two)
        createTap(on: a3, type: .three)
        createTap(on: b1, type: .four)
        createTap(on: b2, type: .five)
        createTap(on: b3, type: .six)
        createTap(on: c1, type: .seven)
        createTap(on: c2, type: .eight)
        createTap(on: c3, type: .nine)

    }
    @IBOutlet weak var computerScore3: UILabel!

    func createTap(on imageView: UIImageView, type box: Box2){
        let tap = UITapGestureRecognizer(target: self, action: #selector(self.boxClicked(_:)))
        tap.name = box.rawValue
        imageView.isUserInteractionEnabled = true
        imageView.addGestureRecognizer(tap)
    }
    @objc func boxClicked(_ sender: UITapGestureRecognizer){
        //        print("Box: \(sender.name) was clicked")
        let selectedBox = getBox(from: sender.name ?? "")
        makeChoice(selectedBox)
        playerChoices.append(Box2(rawValue: sender.name!)!)
        checkIfWon()

        DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
            self.computerPlay()
        }
    }
    func computerPlay(){
        var availableSpaces = [UIImageView]()
        var availableBoxes = [Box2]()
        for name in Box2.allCases {
            let box = getBox(from: name.rawValue)
            if box.image == nil {
                availableSpaces.append(box)
                availableBoxes.append(name)
            }
        }

        guard availableBoxes.count > 0 else { return }

// THIS IS WERE I NEED HELP!
// If AI can win, than win
    //If AI cant win, than block
    // If AI cant block, then take middle source
    //If AI cant take middle square, take random available square

 let randIndex = Int.random(in: 0 ..< availableSpaces.count)
        makeChoice(availableSpaces[randIndex])
        computerChoices.append(availableBoxes[randIndex])
        checkIfWon()
    }

    func makeChoice(_ selectedBox: UIImageView) {
        guard selectedBox.image == nil else { return }

        if gameP1 == "x" {
            selectedBox.image = #imageLiteral(resourceName: "O")
            gameP1 = "o"
        } else {
            selectedBox.image = #imageLiteral(resourceName: "x")
            gameP1 = "x"
        }
    }
    func checkIfWon() {
        var correct = [[Box2]]()
        let firstRow: [Box2] = [.one, .two, .three]
        let secondRow: [Box2] = [.four, .five, .six]
        let thirdRow: [Box2] = [.seven, .eight, .nine]

        let firstCol: [Box2] = [.one, .four, .seven]
        let secondCol: [Box2] = [.two, .five, .six]
        let thirdCol: [Box2] = [.three, .six, .nine]

        let backwardSlash: [Box2] = [.one, .five, .nine]
        let forwardSlash: [Box2] = [.three, .five, .seven]

        correct.append(firstRow)
        correct.append(secondRow)
        correct.append(thirdRow)
        correct.append(firstCol)
        correct.append(secondCol)
        correct.append(thirdCol)
        correct.append(backwardSlash)
        correct.append(forwardSlash)

        for valid in correct {
            let userMatch = playerChoices.filter { valid.contains($0) }.count
            let computerMatch = computerChoices.filter { valid.contains($0) }.count

            if userMatch == valid.count {
                playerScore3.text = String((Int(playerScore3.text ?? "0") ?? 0) + 1)
                resetGame()
                break
            } else if computerMatch == valid.count {
                computerScore3.text = String((Int(computerScore3.text ?? "0") ?? 0) + 1)
                resetGame()
                break
            } else if computerChoices.count + playerChoices.count == 9 {
                resetGame()
                break
            }
        }

    }
    func resetGame() {
        for name in Box2.allCases {
            let box = getBox(from: name.rawValue)
            box.image = nil
        }
        gameP1 = "o"
        playerChoices = []
        computerChoices = []
    }

    func getBox(from name: String) -> UIImageView {
        let box = Box2(rawValue: name) ?? .one

        switch box {
        case .one:
            return a1
        case .two:
            return a2
        case .three:
            return a3
        case .four:
            return b1
        case .five:
            return b2
        case .six:
            return b3
        case .seven:
            return c1
        case .eight:
            return c2
        case .nine:
            return c3
        }
    }

    @IBAction func dice(_ sender: Any) {
        backgroundLabel.image = [ #imageLiteral(resourceName: "Screen Shot 2022-08-10 at 10.52.27 PM"), #imageLiteral(resourceName: "Screen Shot 2022-08-10 at 12.18.19 AM"),  #imageLiteral(resourceName: "Screen Shot 2022-07-04 at 3.43.07 PM"), #imageLiteral(resourceName: "Screen Shot 2022-08-10 at 10.53.00 PM"),  #imageLiteral(resourceName: "Screen Shot 2022-08-10 at 11.56.06 PM"), #imageLiteral(resourceName: "Screen Shot 2022-07-04 at 3.11.02 PM"),  #imageLiteral(resourceName: "Ice Cream In Paper Cut Background"), #imageLiteral(resourceName: "Screen Shot 2022-07-04 at 3.11.02 PM"), #imageLiteral(resourceName: "Screen Shot 2022-08-10 at 12.28.13 AM"), #imageLiteral(resourceName: "Screen Shot 2022-08-10 at 10.52.03 PM"),  #imageLiteral(resourceName: "IMG_9062"),  #imageLiteral(resourceName: "IMG_9064"), #imageLiteral(resourceName: "IMG_9061"), #imageLiteral(resourceName: "IMG_9063"), #imageLiteral(resourceName: "IMG_9065"), #imageLiteral(resourceName: "Screen Shot 2022-07-04 at 3.10.05 PM"), #imageLiteral(resourceName: "backPinkbirth"), #imageLiteral(resourceName: "skybackground"), ][Int.random(in: 0...17)]
    }

    @IBAction func refresh(_ sender: Any) {
        self.dismiss(animated: true, completion: nil)
    }
    enum Box2: String, CaseIterable{
        case one, two, three, four, five, six, seven, eight, nine
    }

}


问:
Django dynamic localization not working as expected on mobile devices
I have question about show current language on mobile devices if I populate my language list in template dynamically (got from languages array from settings)...
So, this code working properly:

```<code><a href="#" id="language-en" class="pure-drawer-link{% if LANGUAGE_CODE == 'en' %} active{% endif %}"> EN </a>
</code>```

BUT, when I'm trying this code, I can't achive that active class added to current language:

```<code>{% for lng in settings.LANGUAGES %}
                                    {% if not lng.0 == "ru" %}
                                        <a href="#" id="language-{{ lng.0 }}"
                                           class="pure-drawer-link{% if LANGUAGE_CODE == '{{ lng.0 }}' %} active{% endif %}">
                                            {{ lng.0|upper }}
                                        </a>
                                        {% if LANGUAGE_CODE == '{{ lng.0 }}' %} active {% else %} nonactive{% endif %} => this always return nonactive
                                    {% endif %}
                                {% endfor %}
</code>```

Can anyone help to understood why this is happening?

EDIT 1:

My middlewars in settings:

```<code>MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'my_app.middleware.ExpirationMiddleware',
    'my_app.middleware.IPMiddleware',
    'my_app.middleware.TranslationMiddleware',
   ]
</code>```

and this for i18:

```<code>USE_I18N = True

USE_L10N = False

USE_TZ = True

TIME_ZONE = 'Europe/Zurich'

LANGUAGE_CODE = 'en-US'
</code>```

Body:
I have question about show current language on mobile devices if I populate my language list in template dynamically (got from languages array from settings)...
So, this code working properly:

 EN

BUT, when I'm trying this code, I can't achive that active class added to current language:

{% for lng in settings.LANGUAGES %}
                                    {% if not lng.0 == "ru" %}

                                            {{ lng.0|upper }}

                                        {% if LANGUAGE_CODE == '{{ lng.0 }}' %} active {% else %} nonactive{% endif %} => this always return nonactive
                                    {% endif %}
                                {% endfor %}

Can anyone help to understood why this is happening?

EDIT 1:

My middlewars in settings:

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'my_app.middleware.ExpirationMiddleware',
    'my_app.middleware.IPMiddleware',
    'my_app.middleware.TranslationMiddleware',
   ]

and this for i18:

USE_I18N = True

USE_L10N = False

USE_TZ = True

TIME_ZONE = 'Europe/Zurich'

LANGUAGE_CODE = 'en-US'


问:
java.lang.ClassNotFoundException: LocalDate from [Module "deployment.modulename-2.11-SNAPSHOT.war:main" from Service Module Loader
Getting the following error when trying to hit request from postman, the class is fetched from a dependent repo by adding the dependency to the current repo. There one field have been changed the type from String to LocalDate

JBOSS_HOME: "D:\Sotwares\jboss-eap-6.4"
JAVA: "C:\Program Files\Java\jdk1.8.0_202\bin\java"

error trace :
13:55:32,172 ERROR [stderr] (http-127.0.0.1:8080-3) java.lang.ClassNotFoundException: LocalDate from [Module "deployment.modulename-2.11-SNAPSHOT.war:main" from Service Module Loader]
13:55:32,173 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:211)
13:55:32,173 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459)
13:55:32,173 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408)
13:55:32,174 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389)
13:55:32,174 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134)
13:55:32,174 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.util.ReflectionUtils.loadClassByName(ReflectionUtils.java:44)
13:55:32,174 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.getInnerType(ModelResolver.java:623)
13:55:32,174 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:323)
13:55:32,175 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:127)
13:55:32,175 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.converter.ModelConverterContextImpl.resolve(ModelConverterContextImpl.java:99)
13:55:32,175 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:106)
13:55:32,175 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:71)
13:55:32,176 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.converter.ModelConverterContextImpl.resolveProperty(ModelConverterContextImpl.java:79)
13:55:32,176 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:342)
13:55:32,176 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:127)
13:55:32,176 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.converter.ModelConverterContextImpl.resolve(ModelConverterContextImpl.java:99)
13:55:32,176 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:106)
13:55:32,178 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:71)
13:55:32,178 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.converter.ModelConverterContextImpl.resolveProperty(ModelConverterContextImpl.java:79)
13:55:32,178 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:87)
13:55:32,178 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:71)
13:55:32,179 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.converter.ModelConverterContextImpl.resolveProperty(ModelConverterContextImpl.java:79)
13:55:32,179 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:324)
13:55:32,179 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:127)
13:55:32,179 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.converter.ModelConverterContextImpl.resolve(ModelConverterContextImpl.java:99)
13:55:32,179 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:106)
13:55:32,180 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:71)
13:55:32,180 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.converter.ModelConverterContextImpl.resolveProperty(ModelConverterContextImpl.java:79)
13:55:32,221 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:87)
13:55:32,221 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:71)
13:55:32,222 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.converter.ModelConverterContextImpl.resolveProperty(ModelConverterContextImpl.java:79)
13:55:32,222 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:324)
13:55:32,222 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:127)
13:55:32,222 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.converter.ModelConverterContextImpl.resolve(ModelConverterContextImpl.java:99)
13:55:32,222 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:106)
13:55:32,223 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:71)
13:55:32,224 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.converter.ModelConverterContextImpl.resolveProperty(ModelConverterContextImpl.java:79)
13:55:32,224 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.converter.ModelConverters.readAsProperty(ModelConverters.java:58)
13:55:32,224 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jaxrs.Reader.parseMethod(Reader.java:784)
13:55:32,224 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jaxrs.Reader.read(Reader.java:293)
13:55:32,225 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jaxrs.Reader.read(Reader.java:145)
13:55:32,225 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jaxrs.config.BeanConfig.scanAndRead(BeanConfig.java:223)
13:55:32,225 ERROR [stderr] (http-127.0.0.1:8080-3)     at io.swagger.jaxrs.config.BeanConfig.setScan(BeanConfig.java:204)
13:55:32,225 ERROR [stderr] (http-127.0.0.1:8080-3)     at com.company.hotel.shop.rest.JaxRsApplication.(JaxRsApplication.java:18)
13:55:32,225 ERROR [stderr] (http-127.0.0.1:8080-3)     at com.company.hotel.shop.rest.JaxRsApplication$Proxy$_$$WeldClientProxy.(JaxRsApplication$Proxy$$$_WeldClientProxy.java)
13:55:32,226 ERROR [stderr] (http-127.0.0.1:8080-3)     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
13:55:32,226 ERROR [stderr] (http-127.0.0.1:8080-3)     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
13:55:32,226 ERROR [stderr] (http-127.0.0.1:8080-3)     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
13:55:32,226 ERROR [stderr] (http-127.0.0.1:8080-3)     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
13:55:32,226 ERROR [stderr] (http-127.0.0.1:8080-3)     at java.lang.Class.newInstance(Class.java:442)
13:55:32,227 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.weld.util.reflection.SecureReflections$16.work(SecureReflections.java:344)
13:55:32,227 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
13:55:32,227 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInstantiation(SecureReflectionAccess.java:173)
13:55:32,227 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.weld.util.reflection.SecureReflections.newInstance(SecureReflections.java:341)
13:55:32,227 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.weld.bean.proxy.ProxyFactory.create(ProxyFactory.java:254)
13:55:32,228 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.weld.bean.proxy.ClientProxyFactory.create(ClientProxyFactory.java:105)
13:55:32,228 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.weld.bean.proxy.ClientProxyProvider.createClientProxy(ClientProxyProvider.java:87)
13:55:32,228 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.weld.bean.proxy.ClientProxyProvider.access$000(ClientProxyProvider.java:43)
13:55:32,228 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.weld.bean.proxy.ClientProxyProvider$1.load(ClientProxyProvider.java:53)
13:55:32,229 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.weld.bean.proxy.ClientProxyProvider$1.load(ClientProxyProvider.java:46)
13:55:32,229 ERROR [stderr] (http-127.0.0.1:8080-3)     at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3589)
13:55:32,229 ERROR [stderr] (http-127.0.0.1:8080-3)     at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2374)
13:55:32,229 ERROR [stderr] (http-127.0.0.1:8080-3)     at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2337)
13:55:32,229 ERROR [stderr] (http-127.0.0.1:8080-3)     at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2252)
13:55:32,230 ERROR [stderr] (http-127.0.0.1:8080-3)     at com.google.common.cache.LocalCache.get(LocalCache.java:3990)
13:55:32,230 ERROR [stderr] (http-127.0.0.1:8080-3)     at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3994)
13:55:32,230 ERROR [stderr] (http-127.0.0.1:8080-3)     at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4878)
13:55:32,230 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.weld.util.cache.LoadingCacheUtils.getCacheValue(LoadingCacheUtils.java:49)
13:55:32,231 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.weld.util.cache.LoadingCacheUtils.getCastCacheValue(LoadingCacheUtils.java:73)
13:55:32,231 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.weld.bean.proxy.ClientProxyProvider.getClientProxy(ClientProxyProvider.java:102)
13:55:32,231 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:621)
13:55:32,231 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:653)
13:55:32,231 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.resteasy.cdi.CdiConstructorInjector.construct(CdiConstructorInjector.java:65)
13:55:32,232 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.resteasy.spi.ResteasyDeployment.createFromInjectorFactory(ResteasyDeployment.java:293)
13:55:32,232 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.resteasy.spi.ResteasyDeployment.createApplication(ResteasyDeployment.java:270)
13:55:32,232 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:228)
13:55:32,232 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:67)
13:55:32,232 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36)
13:55:32,233 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1206)
13:55:32,233 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:962)
13:55:32,233 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:152)
13:55:32,233 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)
13:55:32,233 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
13:55:32,234 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
13:55:32,234 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
13:55:32,234 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151)
13:55:32,234 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)
13:55:32,235 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)
13:55:32,235 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
13:55:32,235 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
13:55:32,235 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:656)
13:55:32,235 ERROR [stderr] (http-127.0.0.1:8080-3)     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926)
13:55:32,236 ERROR [stderr] (http-127.0.0.1:8080-3)     at java.lang.Thread.run(Thread.java:748)
13:55:32,248 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/path/v2].[com.company.hotel.shop.rest.JaxRsApplication]] (http-127.0.0.1:8080-3) JBWEB000235: Allocate exception for servlet com.company.hotel.shop.rest.JaxRsApplication: java.lang.IllegalArgumentException: Unrecognized Type: [null]
at com.fasterxml.jackson.databind.type.TypeFactory.constructType(TypeFactory.java:406) [jackson-databind-2.4.5.jar:2.4.5]
at com.fasterxml.jackson.databind.type.TypeFactory.constructType(TypeFactory.java:354) [jackson-databind-2.4.5.jar:2.4.5]
at com.fasterxml.jackson.databind.ObjectMapper.constructType(ObjectMapper.java:1202) [jackson-databind-2.4.5.jar:2.4.5]
at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:71) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.converter.ModelConverterContextImpl.resolveProperty(ModelConverterContextImpl.java:79) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:324) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:127) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.converter.ModelConverterContextImpl.resolve(ModelConverterContextImpl.java:99) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:106) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:71) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.converter.ModelConverterContextImpl.resolveProperty(ModelConverterContextImpl.java:79) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:342) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:127) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.converter.ModelConverterContextImpl.resolve(ModelConverterContextImpl.java:99) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:106) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:71) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.converter.ModelConverterContextImpl.resolveProperty(ModelConverterContextImpl.java:79) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:87) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:71) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.converter.ModelConverterContextImpl.resolveProperty(ModelConverterContextImpl.java:79) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:324) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:127) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.converter.ModelConverterContextImpl.resolve(ModelConverterContextImpl.java:99) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:106) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:71) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.converter.ModelConverterContextImpl.resolveProperty(ModelConverterContextImpl.java:79) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:87) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:71) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.converter.ModelConverterContextImpl.resolveProperty(ModelConverterContextImpl.java:79) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:324) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:127) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.converter.ModelConverterContextImpl.resolve(ModelConverterContextImpl.java:99) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:106) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:71) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.converter.ModelConverterContextImpl.resolveProperty(ModelConverterContextImpl.java:79) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.converter.ModelConverters.readAsProperty(ModelConverters.java:58) [swagger-core-1.5.9.jar:1.5.9]
at io.swagger.jaxrs.Reader.parseMethod(Reader.java:784) [swagger-jaxrs-1.5.9.jar:1.5.9]
at io.swagger.jaxrs.Reader.read(Reader.java:293) [swagger-jaxrs-1.5.9.jar:1.5.9]
at io.swagger.jaxrs.Reader.read(Reader.java:145) [swagger-jaxrs-1.5.9.jar:1.5.9]
at io.swagger.jaxrs.config.BeanConfig.scanAndRead(BeanConfig.java:223) [swagger-jaxrs-1.5.9.jar:1.5.9]
at io.swagger.jaxrs.config.BeanConfig.setScan(BeanConfig.java:204) [swagger-jaxrs-1.5.9.jar:1.5.9]
at com.company.hotel.shop.rest.JaxRsApplication.(JaxRsApplication.java:18) [classes:]
at com.company.hotel.shop.rest.JaxRsApplication$Proxy$$$WeldClientProxy.(JaxRsApplication$Proxy$$$_WeldClientProxy.java) [classes:]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.8.0_202]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [rt.jar:1.8.0_202]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.8.0_202]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) [rt.jar:1.8.0_202]
at java.lang.Class.newInstance(Class.java:442) [rt.jar:1.8.0_202]
at org.jboss.weld.util.reflection.SecureReflections$16.work(SecureReflections.java:344) [weld-core-1.1.34.Final-redhat-1.jar:1.1.34.Final-redhat-1]
at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52) [weld-core-1.1.34.Final-redhat-1.jar:1.1.34.Final-redhat-1]
at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInstantiation(SecureReflectionAccess.java:173) [weld-core-1.1.34.Final-redhat-1.jar:1.1.34.Final-redhat-1]
at org.jboss.weld.util.reflection.SecureReflections.newInstance(SecureReflections.java:341) [weld-core-1.1.34.Final-redhat-1.jar:1.1.34.Final-redhat-1]
at org.jboss.weld.bean.proxy.ProxyFactory.create(ProxyFactory.java:254) [weld-core-1.1.34.Final-redhat-1.jar:1.1.34.Final-redhat-1]
at org.jboss.weld.bean.proxy.ClientProxyFactory.create(ClientProxyFactory.java:105) [weld-core-1.1.34.Final-redhat-1.jar:1.1.34.Final-redhat-1]
at org.jboss.weld.bean.proxy.ClientProxyProvider.createClientProxy(ClientProxyProvider.java:87) [weld-core-1.1.34.Final-redhat-1.jar:1.1.34.Final-redhat-1]
at org.jboss.weld.bean.proxy.ClientProxyProvider.access$000(ClientProxyProvider.java:43) [weld-core-1.1.34.Final-redhat-1.jar:1.1.34.Final-redhat-1]
at org.jboss.weld.bean.proxy.ClientProxyProvider$1.load(ClientProxyProvider.java:53) [weld-core-1.1.34.Final-redhat-1.jar:1.1.34.Final-redhat-1]
at org.jboss.weld.bean.proxy.ClientProxyProvider$1.load(ClientProxyProvider.java:46) [weld-core-1.1.34.Final-redhat-1.jar:1.1.34.Final-redhat-1]
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3589) [guava-18.0.jar:]
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2374) [guava-18.0.jar:]
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2337) [guava-18.0.jar:]
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2252) [guava-18.0.jar:]
at com.google.common.cache.LocalCache.get(LocalCache.java:3990) [guava-18.0.jar:]
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3994) [guava-18.0.jar:]
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4878) [guava-18.0.jar:]
at org.jboss.weld.util.cache.LoadingCacheUtils.getCacheValue(LoadingCacheUtils.java:49) [weld-core-1.1.34.Final-redhat-1.jar:1.1.34.Final-redhat-1]
at org.jboss.weld.util.cache.LoadingCacheUtils.getCastCacheValue(LoadingCacheUtils.java:73) [weld-core-1.1.34.Final-redhat-1.jar:1.1.34.Final-redhat-1]
at org.jboss.weld.bean.proxy.ClientProxyProvider.getClientProxy(ClientProxyProvider.java:102) [weld-core-1.1.34.Final-redhat-1.jar:1.1.34.Final-redhat-1]
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:621) [weld-core-1.1.34.Final-redhat-1.jar:1.1.34.Final-redhat-1]
at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:653) [weld-core-1.1.34.Final-redhat-1.jar:1.1.34.Final-redhat-1]
at org.jboss.resteasy.cdi.CdiConstructorInjector.construct(CdiConstructorInjector.java:65) [resteasy-cdi-2.3.22.Final-redhat-1.jar:]
at org.jboss.resteasy.spi.ResteasyDeployment.createFromInjectorFactory(ResteasyDeployment.java:293) [resteasy-jaxrs-2.3.22.Final-redhat-1.jar:]
at org.jboss.resteasy.spi.ResteasyDeployment.createApplication(ResteasyDeployment.java:270) [resteasy-jaxrs-2.3.22.Final-redhat-1.jar:]
at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:228) [resteasy-jaxrs-2.3.22.Final-redhat-1.jar:]
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:67) [resteasy-jaxrs-2.3.22.Final-redhat-1.jar:]
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36) [resteasy-jaxrs-2.3.22.Final-redhat-1.jar:]
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1206) [jbossweb-7.5.26.Final-redhat-1.jar:7.5.26.Final-redhat-1]
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:962) [jbossweb-7.5.26.Final-redhat-1.jar:7.5.26.Final-redhat-1]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:152) [jbossweb-7.5.26.Final-redhat-1.jar:7.5.26.Final-redhat-1]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.5.26.Final-redhat-1.jar:7.5.26.Final-redhat-1]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.5.18.Final-redhat-1.jar:7.5.18.Final-redhat-1]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.5.18.Final-redhat-1.jar:7.5.18.Final-redhat-1]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.5.18.Final-redhat-1.jar:7.5.18.Final-redhat-1]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:151) [jbossweb-7.5.26.Final-redhat-1.jar:7.5.26.Final-redhat-1]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.5.26.Final-redhat-1.jar:7.5.26.Final-redhat-1]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.5.26.Final-redhat-1.jar:7.5.26.Final-redhat-1]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [jbossweb-7.5.26.Final-redhat-1.jar:7.5.26.Final-redhat-1]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) [jbossweb-7.5.26.Final-redhat-1.jar:7.5.26.Final-redhat-1]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:656) [jbossweb-7.5.26.Final-redhat-1.jar:7.5.26.Final-redhat-1]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926) [jbossweb-7.5.26.Final-redhat-1.jar:7.5.26.Final-redhat-1]
at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_202]

Tried by importing org.joda.time.LocalDate.


问:
angular http returns data without foreign keys
the application uses java sprin boot framework as backend.
In the class Produit.java there are two foreign keys:
Categorie.java and Laboratoire.java
and they are both created in the database.

Produit.java
`

```<code>@Entity
@Data
public class Produit
{
    @Id @GeneratedValue
    private Long id;

    @ManyToMany(mappedBy = "produits") @JsonIgnore @OnDelete(action = OnDeleteAction.CASCADE)
    private List<Facture> factures;

    @ManyToMany(mappedBy = "produits") @JsonIgnore @OnDelete(action = OnDeleteAction.CASCADE)
    private List<Utilisateur> utilisateurs;

    @ManyToOne @JsonIgnore
    private Categorie categorie;

    @ManyToOne @JsonIgnore
    private Laboratoire laboratoire;

    @OneToMany(mappedBy = "produit") @OnDelete(action = OnDeleteAction.CASCADE) @JsonIgnore
    private List<Commande> commandes;

    private String lib;
    private String description;
    private Double prix;
    @DateTimeFormat(pattern = "dd-MM-yyyy")
    @JsonFormat(pattern = "dd-MM-yyyy")
    private Date dateAjout;
    private Float prixLiv;
}
</code>```

`

Categorie.java
`

```<code>@Entity
@Data
public class Categorie
{
    @Id @GeneratedValue
    private Long id;

    @OneToMany(mappedBy = "categorie") @JsonIgnore @OnDelete(action = OnDeleteAction.CASCADE)
    private List<Produit> produits;

    private String lib;
}
</code>```

`

Laboratoire.java
`

```<code>@Entity
@Data
public class Laboratoire
{
    @Id
    @GeneratedValue
    private Long id;

    @OneToMany(mappedBy = "laboratoire")
    @OnDelete(action = OnDeleteAction.CASCADE) @JsonIgnore
    private List<Produit> produits;

    private String lib;

}
</code>```

`

here are these objects in angular

Produit.ts
`

```<code>export class Produit
{
  id?:number
  lib?:string
  description?:string
  categorie?:Categorie
  laboratoire?:Laboratoire
  dateAjout?:Date
  prix?:number
  prixLiv?:number
}
</code>```

`

But when using the http post method it returns the object without the foreign keys
console outupt

i tryed to change the attribute names but it didn't work

ProduitService.java
`

```<code>@Service
public class ProduitService
{
    @Autowired
    ProduitRepository pr;

    @Transactional
    public List<Produit> findAll() { return pr.findAll(); }

    @Transactional
    public Produit add(Produit produit) { return pr.save(produit); }
}
</code>```

`

ProduitController.java
`

```<code>@RestController
@RequestMapping("produits")
@CrossOrigin(origins = "http://localhost:4200")
public class ProduitController
{
    @Autowired
    ProduitService ps;

    @GetMapping("findAll")
    public List<Produit> findAll() { return ps.findAll(); }

    @PostMapping("add")
    public Produit add(@RequestBody Produit produit) { return ps.add(produit); }
}
</code>```

`

Body:
the application uses java sprin boot framework as backend.
In the class Produit.java there are two foreign keys:
Categorie.java and Laboratoire.java
and they are both created in the database.

Produit.java
`

@Entity
@Data
public class Produit
{
    @Id @GeneratedValue
    private Long id;

    @ManyToMany(mappedBy = "produits") @JsonIgnore @OnDelete(action = OnDeleteAction.CASCADE)
    private List<Facture> factures;

    @ManyToMany(mappedBy = "produits") @JsonIgnore @OnDelete(action = OnDeleteAction.CASCADE)
    private List<Utilisateur> utilisateurs;

    @ManyToOne @JsonIgnore
    private Categorie categorie;

    @ManyToOne @JsonIgnore
    private Laboratoire laboratoire;

    @OneToMany(mappedBy = "produit") @OnDelete(action = OnDeleteAction.CASCADE) @JsonIgnore
    private List<Commande> commandes;

    private String lib;
    private String description;
    private Double prix;
    @DateTimeFormat(pattern = "dd-MM-yyyy")
    @JsonFormat(pattern = "dd-MM-yyyy")
    private Date dateAjout;
    private Float prixLiv;
}

`

Categorie.java
`

@Entity
@Data
public class Categorie
{
    @Id @GeneratedValue
    private Long id;

    @OneToMany(mappedBy = "categorie") @JsonIgnore @OnDelete(action = OnDeleteAction.CASCADE)
    private List<Produit> produits;

    private String lib;
}

`

Laboratoire.java
`

@Entity
@Data
public class Laboratoire
{
    @Id
    @GeneratedValue
    private Long id;

    @OneToMany(mappedBy = "laboratoire")
    @OnDelete(action = OnDeleteAction.CASCADE) @JsonIgnore
    private List<Produit> produits;

    private String lib;

}

`

here are these objects in angular

Produit.ts
`

export class Produit
{
  id?:number
  lib?:string
  description?:string
  categorie?:Categorie
  laboratoire?:Laboratoire
  dateAjout?:Date
  prix?:number
  prixLiv?:number
}

`

But when using the http post method it returns the object without the foreign keys
console outupt

i tryed to change the attribute names but it didn't work

ProduitService.java
`

@Service
public class ProduitService
{
    @Autowired
    ProduitRepository pr;

    @Transactional
    public List<Produit> findAll() { return pr.findAll(); }

    @Transactional
    public Produit add(Produit produit) { return pr.save(produit); }
}

`

ProduitController.java
`

@RestController
@RequestMapping("produits")
@CrossOrigin(origins = "http://localhost:4200")
public class ProduitController
{
    @Autowired
    ProduitService ps;

    @GetMapping("findAll")
    public List<Produit> findAll() { return ps.findAll(); }

    @PostMapping("add")
    public Produit add(@RequestBody Produit produit) { return ps.add(produit); }
}

`


问:
How to display sub-images with correct spacings?

Here is a sample plot with ten subimages:

```<code>import numpy as np
import matplotlib.pyplot as plt

fig, axes = plt.subplots(2, 5)
fig.suptitle('Sample Images')
for i in range(0, axes.shape[0]):
    for j in range(0, axes.shape[1]):
        k = i * axes.shape[1] + j
        axes[i][j].imshow(np.random.rand(28, 28))
        axes[i][j].title.set_text('%d, %d' % (i+1, j+1))
        axes[i][j].set_axis_off()
fig.show()
</code>```

Vertical spaces are too big:

If I add tight_layout():

```<code>fig.tight_layout(pad=0, h_pad=0, w_pad=0)
</code>```

Then horizontal spaces are increased:

If I set fugure size explicitly:

```<code>fig, axes = plt.subplots(2, 5, figsize=(5,2))
</code>```

Then spaces are fine, but there is a problem with titles:

How to fix it? So spaces are small and titles are fine?

I guess that the problem is caused by default image size. For instance, if I don't generate images for last column:

```<code>fig, axes = plt.subplots(2, 5)
fig.suptitle('Sample Images')
for i in range(0, axes.shape[0]):
    for j in range(0, axes.shape[1]-1):
        k = i * axes.shape[1] + j
        axes[i][j].imshow(np.random.rand(28, 28))
        axes[i][j].title.set_text('%d, %d' % (i+1, j+1))
        axes[i][j].set_axis_off()
fig.show()
</code>```

Then I see that spaces are fine:

The problem is that too much vertical space is reserved for images by default. Is it possible to force size of each subimage to be 28x28 pixels?

Body:
Here is a sample plot with ten subimages:

import numpy as np
import matplotlib.pyplot as plt

fig, axes = plt.subplots(2, 5)
fig.suptitle('Sample Images')
for i in range(0, axes.shape[0]):
    for j in range(0, axes.shape[1]):
        k = i * axes.shape[1] + j
        axes[i][j].imshow(np.random.rand(28, 28))
        axes[i][j].title.set_text('%d, %d' % (i+1, j+1))
        axes[i][j].set_axis_off()
fig.show()

Vertical spaces are too big:

If I add tight_layout():

fig.tight_layout(pad=0, h_pad=0, w_pad=0)

Then horizontal spaces are increased:

If I set fugure size explicitly:

fig, axes = plt.subplots(2, 5, figsize=(5,2))

Then spaces are fine, but there is a problem with titles:

How to fix it? So spaces are small and titles are fine?

I guess that the problem is caused by default image size. For instance, if I don't generate images for last column:

fig, axes = plt.subplots(2, 5)
fig.suptitle('Sample Images')
for i in range(0, axes.shape[0]):
    for j in range(0, axes.shape[1]-1):
        k = i * axes.shape[1] + j
        axes[i][j].imshow(np.random.rand(28, 28))
        axes[i][j].title.set_text('%d, %d' % (i+1, j+1))
        axes[i][j].set_axis_off()
fig.show()

Then I see that spaces are fine:

The problem is that too much vertical space is reserved for images by default. Is it possible to force size of each subimage to be 28x28 pixels?


问:
Hibernate error: No Persistence provider for EntityManager named HibernateEjemplo1
I'm a programming student and this is my first contact with Hibernate.

When trying to make a program with netbeans 16 and JDK 19, using Hibernate to connect to a SQL database I get the following error.

```<code>
    Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named HibernateEjemplo1
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:61)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
        at test.HolaMundoHibernate.main(HolaMundoHibernate.java:12)
    Command execution failed.

</code>```

Following an internet tutorial I have done the following:

I have created the database called test and the table called persona with SQL.

I have created a java Maven project, called HibernateExample1 with Netbeans 16 and JDK 19.

I have modified the pom.xml file to add dependencies. I have only added the ones highlighted in blue, the rest have been added by themselves by doing clean & build in the project.

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>mx.com.gm</groupId>
        <artifactId>HibernateEjemplo1</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>jar</packaging>
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <maven.compiler.source>19</maven.compiler.source>
            <maven.compiler.target>19</maven.compiler.target>
            <exec.mainClass>HibernateEjemplo1</exec.mainClass>
        </properties>
        <dependencies>
            <dependency>
                <groupId>org.hibernate.orm</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>6.1.6.Final</version>
            </dependency>
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>8.0.28</version>
            </dependency>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-api</artifactId>
                <version>2.13.0</version>
            </dependency>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-core</artifactId>
                <version>2.13.0</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate.javax.persistence</groupId>
                <artifactId>hibernate-jpa-2.1-api</artifactId>
                <version>1.0.0.Final</version>
                <type>jar</type>
            </dependency>
            <dependency>
                <groupId>org.eclipse.persistence</groupId>
                <artifactId>org.eclipse.persistence.core</artifactId>
                <version>2.7.10</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.persistence</groupId>
                <artifactId>org.eclipse.persistence.asm</artifactId>
                <version>9.2.0</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.persistence</groupId>
                <artifactId>org.eclipse.persistence.antlr</artifactId>
                <version>2.7.10</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.persistence</groupId>
                <artifactId>org.eclipse.persistence.jpa</artifactId>
                <version>2.7.10</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.persistence</groupId>
                <artifactId>org.eclipse.persistence.jpa.jpql</artifactId>
                <version>2.7.10</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.persistence</groupId>
                <artifactId>org.eclipse.persistence.moxy</artifactId>
                <version>2.7.10</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.persistence</groupId>
                <artifactId>jakarta.persistence</artifactId>
                <version>2.2.3</version>
            </dependency>
        </dependencies>
    </project>

```
<ol start="4">
<li><p>I have created the <strong>persistence.xml</strong> file</p>
<pre class="lang-xml prettyprint-override"><code><?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence  http://xmlns.jcp.org/xml/ns/persistence_2_2.xsd">
  <persistence-unit name="HibernateEjemplo1" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <class>mx.com.gm.domain.Persona</class>
    <properties>
      <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/mysql?zeroDateTimeBehavior=CONVERT_TO_NULL"/>
      <property name="javax.persistence.jdbc.user" value="root"/>
      <property name="javax.persistence.jdbc.password" value="password"/>
      <property name="javax.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver"/>
      <property name="hibernate.show_sql" value="true"/>
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
    </properties>
  </persistence-unit>
</persistence>
</code>```

I have created the file log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss} [%t] %-5level %logger{36} - %msg%n"/>
        </Console>
    </Appenders>
    <Loggers>
        <Logger name="org.hibernate.SQL" level="debug" additivity="false">
            <AppenderRef ref="Console"/>
        </Logger>
        <Logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="trace" additivity="false">
            <AppenderRef ref="Console"/>
        </Logger>
        <Root level="info">
            <AppenderRef ref="Console"/>
        </Root>
    </Loggers>
</Configuration>
```
</li>
<li><p>I have created the class <strong>Persona.java</strong> which has the same attributes as my SQL table.</p>
<pre class="lang-java prettyprint-override"><code>package mx.com.gm.domain;

import java.io.Serializable;
import javax.persistence.*;

@Entity
@Table(name = "persona")
public class Persona implements Serializable {

    private static final long serialVersionUID = 1L;

    @Column(name = "id_persona")
    @Id
    private int idPersona;

    private String nombre;

    private String apellido;

    private String email;

    private String telefono;

    public Persona() {
    }

    public int getIdPersona() {
        return idPersona;
    }

    public void setIdPersona(int idPersona) {
        this.idPersona = idPersona;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getApellido() {
        return apellido;
    }

    public void setApellido(String apellido) {
        this.apellido = apellido;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getTelefono() {
        return telefono;
    }

    public void setTelefono(String telefono) {
        this.telefono = telefono;
    }

    @Override
    public String toString() {
        return "Empleados{" + "idPersona=" + idPersona + ", nombre=" + nombre + ", apellido=" + apellido +
                ", email=" + email + ", telefono=" + telefono + '}';
    }

}
    ```

```
</li>
<li><p>And finally, I have created the class <strong>HolaMundoHibernate.java</strong> to run the program.</p>
<pre class="lang-java prettyprint-override"><code>package test;

import java.util.List;
import javax.persistence.*;
import mx.com.gm.domain.Persona;

public class HolaMundoHibernate {
    public static void main(String[] args) {
        String hql = "SELECT p FROM Persona p";
        EntityManagerFactory fabrica = Persistence.createEntityManagerFactory("HibernateEjemplo1");
        EntityManager entityManager = fabrica.createEntityManager();

        Query query = entityManager.createQuery(hql);
        List<Persona> personas = query.getResultList();

        for (Persona p : personas) {
            System.out.println("Persona: " + p);
        }

    }
}
</code>```

When I run the program I get the following error:
No Persistence provider for EntityManager named HibernateEjemplo1

The structure of my project is as follows.

Project structure

Any help is welcome.
Thank you in advance.

Body:
I'm a programming student and this is my first contact with Hibernate.

When trying to make a program with netbeans 16 and JDK 19, using Hibernate to connect to a SQL database I get the following error.

    Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named HibernateEjemplo1
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:61)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
        at test.HolaMundoHibernate.main(HolaMundoHibernate.java:12)
    Command execution failed.

Following an internet tutorial I have done the following:

I have created the database called test and the table called persona with SQL.

I have created a java Maven project, called HibernateExample1 with Netbeans 16 and JDK 19.

I have modified the pom.xml file to add dependencies. I have only added the ones highlighted in blue, the rest have been added by themselves by doing clean & build in the project.

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>mx.com.gm</groupId>
        <artifactId>HibernateEjemplo1</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>jar</packaging>
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <maven.compiler.source>19</maven.compiler.source>
            <maven.compiler.target>19</maven.compiler.target>
            <exec.mainClass>HibernateEjemplo1</exec.mainClass>
        </properties>
        <dependencies>
            <dependency>
                <groupId>org.hibernate.orm</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>6.1.6.Final</version>
            </dependency>
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>8.0.28</version>
            </dependency>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-api</artifactId>
                <version>2.13.0</version>
            </dependency>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-core</artifactId>
                <version>2.13.0</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate.javax.persistence</groupId>
                <artifactId>hibernate-jpa-2.1-api</artifactId>
                <version>1.0.0.Final</version>
                <type>jar</type>
            </dependency>
            <dependency>
                <groupId>org.eclipse.persistence</groupId>
                <artifactId>org.eclipse.persistence.core</artifactId>
                <version>2.7.10</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.persistence</groupId>
                <artifactId>org.eclipse.persistence.asm</artifactId>
                <version>9.2.0</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.persistence</groupId>
                <artifactId>org.eclipse.persistence.antlr</artifactId>
                <version>2.7.10</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.persistence</groupId>
                <artifactId>org.eclipse.persistence.jpa</artifactId>
                <version>2.7.10</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.persistence</groupId>
                <artifactId>org.eclipse.persistence.jpa.jpql</artifactId>
                <version>2.7.10</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.persistence</groupId>
                <artifactId>org.eclipse.persistence.moxy</artifactId>
                <version>2.7.10</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.persistence</groupId>
                <artifactId>jakarta.persistence</artifactId>
                <version>2.2.3</version>
            </dependency>
        </dependencies>
    </project>

I have created the persistence.xml file

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence  http://xmlns.jcp.org/xml/ns/persistence_2_2.xsd">
  <persistence-unit name="HibernateEjemplo1" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <class>mx.com.gm.domain.Persona</class>
    <properties>
      <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/mysql?zeroDateTimeBehavior=CONVERT_TO_NULL"/>
      <property name="javax.persistence.jdbc.user" value="root"/>
      <property name="javax.persistence.jdbc.password" value="password"/>
      <property name="javax.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver"/>
      <property name="hibernate.show_sql" value="true"/>
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
    </properties>
  </persistence-unit>
</persistence>

I have created the file log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss} [%t] %-5level %logger{36} - %msg%n"/>
        </Console>
    </Appenders>
    <Loggers>
        <Logger name="org.hibernate.SQL" level="debug" additivity="false">
            <AppenderRef ref="Console"/>
        </Logger>
        <Logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="trace" additivity="false">
            <AppenderRef ref="Console"/>
        </Logger>
        <Root level="info">
            <AppenderRef ref="Console"/>
        </Root>
    </Loggers>
</Configuration>

I have created the class Persona.java which has the same attributes as my SQL table.

package mx.com.gm.domain;

import java.io.Serializable;
import javax.persistence.*;

@Entity
@Table(name = "persona")
public class Persona implements Serializable {

    private static final long serialVersionUID = 1L;

    @Column(name = "id_persona")
    @Id
    private int idPersona;

    private String nombre;

    private String apellido;

    private String email;

    private String telefono;

    public Persona() {
    }

    public int getIdPersona() {
        return idPersona;
    }

    public void setIdPersona(int idPersona) {
        this.idPersona = idPersona;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getApellido() {
        return apellido;
    }

    public void setApellido(String apellido) {
        this.apellido = apellido;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getTelefono() {
        return telefono;
    }

    public void setTelefono(String telefono) {
        this.telefono = telefono;
    }

    @Override
    public String toString() {
        return "Empleados{" + "idPersona=" + idPersona + ", nombre=" + nombre + ", apellido=" + apellido +
                ", email=" + email + ", telefono=" + telefono + '}';
    }

}
    ```

And finally, I have created the class HolaMundoHibernate.java to run the program.

package test;

import java.util.List;
import javax.persistence.*;
import mx.com.gm.domain.Persona;

public class HolaMundoHibernate {
    public static void main(String[] args) {
        String hql = "SELECT p FROM Persona p";
        EntityManagerFactory fabrica = Persistence.createEntityManagerFactory("HibernateEjemplo1");
        EntityManager entityManager = fabrica.createEntityManager();

        Query query = entityManager.createQuery(hql);
        List<Persona> personas = query.getResultList();

        for (Persona p : personas) {
            System.out.println("Persona: " + p);
        }

    }
}

When I run the program I get the following error:
No Persistence provider for EntityManager named HibernateEjemplo1

The structure of my project is as follows.

Project structure

Any help is welcome.
Thank you in advance.


问:
Powershell SQLite not releasing database file
Im trying to move file after reading database file but im getting error that it is being used by another process.

My code

```<code>$sDatabasePath=testfile.dat
$sDatabaseConnectionString=[string]::Format("data source={0}",$sDatabasePath)
$oSQLiteDBConnection = New-Object System.Data.SQLite.SQLiteConnection
$oSQLiteDBConnection.ConnectionString = $sDatabaseConnectionString
$oSQLiteDBConnection.open()

$oSQLiteDBCommand=$oSQLiteDBConnection.CreateCommand()
$oSQLiteDBCommand.Commandtext="SELECT * from table_id"
$oSQLiteDBCommand.CommandType = [System.Data.CommandType]::Text
$oDBReader=$oSQLiteDBCommand.ExecuteReader()

while($oDBReader.HasRows)
{
    if($oDBReader.Read())
    {
     $resultName = $oDBReader["name"]
    }
}

$oSQLiteDBConnection.close()

Move-Item -Path testfile.dat -Destination /somepath/

</code>```

I found that it helped for others to add system gc collect but no luck for my code and still throws same error.
I just need to close DB connection with releasing file and move file to another location

Body:
Im trying to move file after reading database file but im getting error that it is being used by another process.

My code

$sDatabasePath=testfile.dat
$sDatabaseConnectionString=[string]::Format("data source={0}",$sDatabasePath)
$oSQLiteDBConnection = New-Object System.Data.SQLite.SQLiteConnection
$oSQLiteDBConnection.ConnectionString = $sDatabaseConnectionString
$oSQLiteDBConnection.open()

$oSQLiteDBCommand=$oSQLiteDBConnection.CreateCommand()
$oSQLiteDBCommand.Commandtext="SELECT * from table_id"
$oSQLiteDBCommand.CommandType = [System.Data.CommandType]::Text
$oDBReader=$oSQLiteDBCommand.ExecuteReader()

while($oDBReader.HasRows)
{
    if($oDBReader.Read())
    {
     $resultName = $oDBReader["name"]
    }
}

$oSQLiteDBConnection.close()

Move-Item -Path testfile.dat -Destination /somepath/

I found that it helped for others to add system gc collect but no luck for my code and still throws same error.
I just need to close DB connection with releasing file and move file to another location


问:
pandas remove words beginning with specific char
I have tweets like this sat in a pandas data frame from under a column called "Full Text".

@daviemoo @hiimbarry really excellent piece davie! one of your best i’d say. thank goodness i get this via email - my sky internet has blocked the link to it  also - i get how you feel…..but please don’t le...

How can I iterate through the rows and remove all values in that columns where the string begins with @ such as "@daviemoo"

I have been going down this sort of route but not sure if it is leading anywhere

```<code>df['Full Text'] = [DO_SOMTHING(sentence) for sentence in list(df['Full Text'])]
</code>```

Body:
I have tweets like this sat in a pandas data frame from under a column called "Full Text".

@daviemoo @hiimbarry really excellent piece davie! one of your best i’d say. thank goodness i get this via email - my sky internet has blocked the link to it  also - i get how you feel…..but please don’t le...

How can I iterate through the rows and remove all values in that columns where the string begins with @ such as "@daviemoo"

I have been going down this sort of route but not sure if it is leading anywhere

df['Full Text'] = [DO_SOMTHING(sentence) for sentence in list(df['Full Text'])]


问:
(Rails)Where should i define method that can use in Rspec and Controller?
I'm making method that can used in Rspec test and Controllers.
But i don't know where to store it.

Here are options that i have thought.

application_helper
-> but this file is used for method which used in applicaion controller.

spec_helper.rb

rails_helper.rb
-> these two file is for rspec test

where should i store it?

I read this article but i'm not using models.

How to make a custom method that can be used anywhere in rails app

Now i had stored it at application_helper.rb, and call as

ApplicationController.helpers.custom_method

Is this right practice?


问:
Issues to loop over an object to update table on TypeScript using TypeOrm
I am working on this application and I wanted to implement a single update function that could update any of the table columns or all of them.
This is what my update function looks like:

```<code>  public async updateContract(id: number, data: IContractUpdate): Promise<object> {
  const contract = await contractRepository.findOneBy({ id });
  if(!contract) return { couldExecute: false, message: 'contract not found' };

  for(const [key, newValue] of Object.entries(data)) {
    contract[key] = newValue;
  };

  await contractRepository.save(contract);
  return contract;
};
</code>```

where I have contract[key] = value, under contrack[key] I get a warning with the following error:

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Contract'.
No index signature with a parameter of type 'string' was found on type 'Contract'.ts(7053)

also, data has an interface defining its parameters as follows:

```<code>interface IContractUpdate {
  status?: string
  startDate?: Date
  budget?: number
  endDate?: Date
  expectedEndDate?: Date
  contractTypeId?: number
  customerId?: number
  description?: string
};
</code>```

these are the same parameters I have on my entity that I am trying to update, my goal was to update with contract[parameter] to the same value as data[parameter], but it seems like I can't pass the parameter as a string to the entity.

Anyone has any idea of how to get that to work?

Body:
I am working on this application and I wanted to implement a single update function that could update any of the table columns or all of them.
This is what my update function looks like:

  public async updateContract(id: number, data: IContractUpdate): Promise<object> {
  const contract = await contractRepository.findOneBy({ id });
  if(!contract) return { couldExecute: false, message: 'contract not found' };

  for(const [key, newValue] of Object.entries(data)) {
    contract[key] = newValue;
  };

  await contractRepository.save(contract);
  return contract;
};

where I have contract[key] = value, under contrack[key] I get a warning with the following error:

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Contract'.
No index signature with a parameter of type 'string' was found on type 'Contract'.ts(7053)

also, data has an interface defining its parameters as follows:

interface IContractUpdate {
  status?: string
  startDate?: Date
  budget?: number
  endDate?: Date
  expectedEndDate?: Date
  contractTypeId?: number
  customerId?: number
  description?: string
};

these are the same parameters I have on my entity that I am trying to update, my goal was to update with contract[parameter] to the same value as data[parameter], but it seems like I can't pass the parameter as a string to the entity.

Anyone has any idea of how to get that to work?


问:
Custom routing via nginx based on which application node getting different data from kafka
My applicaion have 3 instance which are reading data from kafka having same group id each node have disjoint data (different data) and client will connect to a socket to the application using nginx but as nginx will load balance it will send request to a particular node so chances are that it will not have data for that. The id in request is same as the partition key of kafka. So is there a solution to route nginx to the correct application which have the data of id as after socket connection there will be continous flow of data from server(data coming from kafka)  to client.</p>